Class: Warchat::Chat::Presence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Presence

Returns a new instance of Presence.



7
8
9
10
11
# File 'lib/warchat/chat/presence.rb', line 7

def initialize response
  @type = response["presenceType"];
  @character = response["character"];
  @name = character["n"];
end

Instance Attribute Details

#characterObject (readonly)

Returns the value of attribute character.



5
6
7
# File 'lib/warchat/chat/presence.rb', line 5

def character
  @character
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/warchat/chat/presence.rb', line 5

def name
  @name
end

Instance Method Details

#offline?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/warchat/chat/presence.rb', line 13

def offline?
  @type and @type.include? 'offline'
end

#typeObject



17
18
19
20
# File 'lib/warchat/chat/presence.rb', line 17

def type 
  return 'unknown' unless @type
  @type.split('_')[1..-1].join '_'
end