Class: Warchat::Chat::Message
- Inherits:
-
Object
- Object
- Warchat::Chat::Message
- Defined in:
- lib/warchat/chat/message.rb
Constant Summary collapse
- CHAT_MSG_TYPE_AFK =
"afk"
- CHAT_MSG_TYPE_DND =
"dnd"
- CHAT_MSG_TYPE_GUILD_CHAT =
"guild_chat"
- CHAT_MSG_TYPE_GUILD_MOTD =
"motd"
- CHAT_MSG_TYPE_OFFICER_CHAT =
"officer_chat"
- CHAT_MSG_TYPE_WHISPER =
"whisper"
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #character ⇒ Object
- #guild ⇒ Object
-
#initialize(response) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(response) ⇒ Message
Returns a new instance of Message.
14 15 16 17 18 19 |
# File 'lib/warchat/chat/message.rb', line 14 def initialize response @response = response @type = response["messageType"] @body = response['body'] @from = (response["from"] or {}) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/warchat/chat/message.rb', line 12 def body @body end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/warchat/chat/message.rb', line 12 def type @type end |
Instance Method Details
#character ⇒ Object
27 28 29 30 31 |
# File 'lib/warchat/chat/message.rb', line 27 def character return @character if @character or @from["characterId"].nil? _,name,realm = @from["characterId"].split(':') @character = Warchat::Models::Character.find_or_create 'n' => name,'r'=>realm end |
#guild ⇒ Object
21 22 23 24 25 |
# File 'lib/warchat/chat/message.rb', line 21 def guild return @guild if @guild or @from["guildId"].nil? _,name,realm = @response['from']["guildId"].split(':') @guild = Warchat::Models::Guild.find_or_create 'n' => name,'r'=>realm end |