Class: Warchat::Chat::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/warchat/chat/message.rb

Constant Summary collapse

CHAT_ID_TYPE_CHARACTER =
"character"
CHAT_ID_TYPE_GUILD =
"guild"
CHAT_ID_TYPE_GUILD_MEMBER =
"guild_member"
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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Message

Returns a new instance of Message.



17
18
19
20
21
22
23
24
25
# File 'lib/warchat/chat/message.rb', line 17

def initialize response
  @type = response["messageType"]
  @body = response['body']
  @from = response["from"]
  if @from
    @from_type = from["chatIdType"]
    @character_id = from["characterId"]
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



15
16
17
# File 'lib/warchat/chat/message.rb', line 15

def body
  @body
end

#character_idObject (readonly)

Returns the value of attribute character_id.



15
16
17
# File 'lib/warchat/chat/message.rb', line 15

def character_id
  @character_id
end

#fromObject (readonly)

Returns the value of attribute from.



15
16
17
# File 'lib/warchat/chat/message.rb', line 15

def from
  @from
end

#from_typeObject (readonly)

Returns the value of attribute from_type.



15
16
17
# File 'lib/warchat/chat/message.rb', line 15

def from_type
  @from_type
end

#typeObject (readonly)

Returns the value of attribute type.



15
16
17
# File 'lib/warchat/chat/message.rb', line 15

def type
  @type
end

Instance Method Details

#character_nameObject



27
28
29
# File 'lib/warchat/chat/message.rb', line 27

def character_name
  @character_id and @character_id.split(':')[-2]
end

#realm_idObject



31
32
33
# File 'lib/warchat/chat/message.rb', line 31

def realm_id
  @character_id and @character_id.split(':').last
end