class YolQyWeixin::Message
Public Class Methods
factory(xml)
click to toggle source
# File lib/yol_qy_weixin/models/message.rb, line 25 def self.factory(xml) hash = MultiXml.parse(xml)['xml'] # 优先检测服务器信息 unless hash['InfoType'].to_s.empty? case hash['InfoType'] when 'component_verify_ticket' TicketMessage.new(hash) when 'unauthorized' AuthorizeMessage.new(hash) else raise ArgumentError, 'Unknown Weixin Message' + hash.to_s end else case hash['MsgType'] when 'text' TextMessage.new(hash) when 'image' ImageMessage.new(hash) when 'location' LocationMessage.new(hash) when 'link' LinkMessage.new(hash) when 'event' EventMessage.new(hash) when 'voice' VoiceMessage.new(hash) when 'video' VideoMessage.new(hash) else raise ArgumentError, 'Unknown Weixin Message' + hash.to_s end end end
new(hash)
click to toggle source
# File lib/yol_qy_weixin/models/message.rb, line 9 def initialize(hash) @source = OpenStruct.new(hash) end
Public Instance Methods
CreateTime()
click to toggle source
# File lib/yol_qy_weixin/models/message.rb, line 17 def CreateTime @source.CreateTime.to_i end
MsgId()
click to toggle source
# File lib/yol_qy_weixin/models/message.rb, line 21 def MsgId @source.MsgId.to_i rescue nil end
method_missing(method, *args, &block)
click to toggle source
# File lib/yol_qy_weixin/models/message.rb, line 13 def method_missing(method, *args, &block) @source.send(method, *args, &block) end