Class: RocketChat::PresenceStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/rocket_chat/presence_status.rb

Overview

Rocket.Chat PresenceStatus

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PresenceStatus

Returns a new instance of PresenceStatus.

Parameters:

  • data (Hash)

    Raw presence status data



12
13
14
# File 'lib/rocket_chat/presence_status.rb', line 12

def initialize(data)
  @data = Util.stringify_hash_keys data
end

Instance Attribute Details

#dataObject (readonly)

Raw presence status data



7
8
9
# File 'lib/rocket_chat/presence_status.rb', line 7

def data
  @data
end

Instance Method Details

#connection_statusObject

Connection status



22
23
24
# File 'lib/rocket_chat/presence_status.rb', line 22

def connection_status
  data['connectionStatus']
end

#inspectObject



33
34
35
36
37
38
39
40
# File 'lib/rocket_chat/presence_status.rb', line 33

def inspect
  format(
    '#<%<class_name>s:0x%<object_id>p @presence="%<presence>s">',
    class_name: self.class.name,
    object_id: object_id,
    presence: presence
  )
end

#last_loginObject

Last login



27
28
29
30
31
# File 'lib/rocket_chat/presence_status.rb', line 27

def 
  Time.parse data['lastLogin']
rescue ArgumentError, TypeError
  nil
end

#presenceObject

Presence



17
18
19
# File 'lib/rocket_chat/presence_status.rb', line 17

def presence
  data['presence']
end