Class: WeChat::Bot::MessageData::ShareCard
- Inherits:
-
Object
- Object
- WeChat::Bot::MessageData::ShareCard
- Defined in:
- lib/wechat/bot/message_data/share_card.rb
Instance Attribute Summary collapse
- #app ⇒ String, Nil readonly
- #description ⇒ String readonly
- #from_user ⇒ String readonly
- #link ⇒ String readonly
- #mp ⇒ Hash<Symbol, String>, Hash<Symbol, Nil> readonly
- #thumb_image ⇒ String, Nil readonly
- #title ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw) ⇒ ShareCard
constructor
A new instance of ShareCard.
- #parse ⇒ Object
Constructor Details
#initialize(raw) ⇒ ShareCard
Returns a new instance of ShareCard.
28 29 30 31 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 28 def initialize(raw) @raw = MultiXml.parse(raw.gsub("<br/>", "")) parse end |
Instance Attribute Details
#app ⇒ String, Nil (readonly)
23 24 25 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 23 def app @app end |
#description ⇒ String (readonly)
14 15 16 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 14 def description @description end |
#from_user ⇒ String (readonly)
20 21 22 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 20 def from_user @from_user end |
#link ⇒ String (readonly)
11 12 13 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 11 def link @link end |
#mp ⇒ Hash<Symbol, String>, Hash<Symbol, Nil> (readonly)
26 27 28 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 26 def mp @mp end |
#thumb_image ⇒ String, Nil (readonly)
17 18 19 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 17 def thumb_image @thumb_image end |
#title ⇒ String (readonly)
8 9 10 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 8 def title @title end |
Class Method Details
.parse(raw) ⇒ Object
3 4 5 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 3 def self.parse(raw) self.new(raw) end |
Instance Method Details
#parse ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wechat/bot/message_data/share_card.rb', line 33 def parse @title = @raw["msg"]["appmsg"]["title"] @link = @raw["msg"]["appmsg"]["url"] @description = @raw["msg"]["appmsg"]["des"] @thumb_image = @raw["msg"]["appmsg"]["thumb_url"] @from_user = @raw["msg"]["fromusername"] @app = @raw["msg"]["appname"] @mp = { username: @raw["msg"]["sourceusername"], nickname: @raw["msg"]["sourcedisplayname"], } end |