Class: WeChat::Bot::MessageData::ShareCard

Inherits:
Object
  • Object
show all
Defined in:
lib/wechat/bot/message_data/share_card.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#appString, Nil (readonly)

Returns:



23
24
25
# File 'lib/wechat/bot/message_data/share_card.rb', line 23

def app
  @app
end

#descriptionString (readonly)

Returns:



14
15
16
# File 'lib/wechat/bot/message_data/share_card.rb', line 14

def description
  @description
end

#from_userString (readonly)

Returns:



20
21
22
# File 'lib/wechat/bot/message_data/share_card.rb', line 20

def from_user
  @from_user
end

Returns:



11
12
13
# File 'lib/wechat/bot/message_data/share_card.rb', line 11

def link
  @link
end

#mpHash<Symbol, String>, Hash<Symbol, Nil> (readonly)

Returns:

  • (Hash<Symbol, String>, Hash<Symbol, Nil>)


26
27
28
# File 'lib/wechat/bot/message_data/share_card.rb', line 26

def mp
  @mp
end

#thumb_imageString, Nil (readonly)

Returns:



17
18
19
# File 'lib/wechat/bot/message_data/share_card.rb', line 17

def thumb_image
  @thumb_image
end

#titleString (readonly)

Returns:



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

#parseObject



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