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.



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

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.



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

def body
  @body
end

#character_idObject (readonly)

Returns the value of attribute character_id.



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

def character_id
  @character_id
end

#fromObject (readonly)

Returns the value of attribute from.



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

def from
  @from
end

#from_typeObject (readonly)

Returns the value of attribute from_type.



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

def from_type
  @from_type
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#character_nameObject



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

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

#realm_idObject



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

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