Class: DingBot::Message::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/dingbot/message/markdown.rb

Overview

markdown类型 {

"msgtype": "markdown",
"markdown": {
    "title":"杭州天气",
    "text": "#### 杭州天气\n" +
        "> 9度,西北风1级,空气良89,相对温度73%\n\n" +
        "> ![screenshot](http://image.jpg)\n"  +
        "> ###### 10点20分发布 [天气](http://www.thinkpage.cn/) \n"
},
"at": {
  "atMobiles": [
  "1825718XXXX"
  ], 
"isAtAll": false
}

}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(title = '', text = '', at_mobiles = [], is_at_all = false) ⇒ Markdown

Returns a new instance of Markdown.



24
25
26
27
28
29
# File 'lib/dingbot/message/markdown.rb', line 24

def initialize(title='', text='', at_mobiles=[], is_at_all=false)
  @title = title
  @text = text
  @at_mobiles = at_mobiles
  @is_at_all = is_at_all
end

Instance Attribute Details

#at_mobilesObject

Returns the value of attribute at_mobiles.



22
23
24
# File 'lib/dingbot/message/markdown.rb', line 22

def at_mobiles
  @at_mobiles
end

#is_at_allObject

Returns the value of attribute is_at_all.



22
23
24
# File 'lib/dingbot/message/markdown.rb', line 22

def is_at_all
  @is_at_all
end

#textObject

Returns the value of attribute text.



22
23
24
# File 'lib/dingbot/message/markdown.rb', line 22

def text
  @text
end

#titleObject

Returns the value of attribute title.



22
23
24
# File 'lib/dingbot/message/markdown.rb', line 22

def title
  @title
end

Instance Method Details

#body_paramsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dingbot/message/markdown.rb', line 35

def body_params
  super.merge({
      markdown: {
          text: @text,
          title: @title,
      },
      at: {
              atMobiles: @at_mobiles,
              isAtAll: @is_at_all
          }
      }
  )
end

#msg_typeObject



31
32
33
# File 'lib/dingbot/message/markdown.rb', line 31

def msg_type
  TYPE::MARKDOWN
end