Class: RocketChat::User

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

Overview

Rocket.Chat User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ User

Returns a new instance of User.

Parameters:

  • data (Hash)

    Raw user data



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

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

Instance Attribute Details

#dataObject (readonly)

Raw user data



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

def data
  @data
end

Instance Method Details

#active?Boolean

User active

Returns:

  • (Boolean)


62
63
64
# File 'lib/rocket_chat/user.rb', line 62

def active?
  data['active']
end

#emailObject

User email



32
33
34
# File 'lib/rocket_chat/user.rb', line 32

def email
  emails.first && emails.first['address']
end

#email_verified?Boolean

User email verified

Returns:

  • (Boolean)


37
38
39
# File 'lib/rocket_chat/user.rb', line 37

def email_verified?
  emails.first && emails.first['verified']
end

#emailsObject

User emails



27
28
29
# File 'lib/rocket_chat/user.rb', line 27

def emails
  data['emails'] || []
end

#idObject

User ID



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

def id
  data['_id']
end

#inspectObject



71
72
73
74
75
76
77
78
79
80
# File 'lib/rocket_chat/user.rb', line 71

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

#nameObject

User name



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

def name
  data['name']
end

#rolesObject

User roles



67
68
69
# File 'lib/rocket_chat/user.rb', line 67

def roles
  data['roles']
end

#statusObject

User status



42
43
44
# File 'lib/rocket_chat/user.rb', line 42

def status
  data['status']
end

#status_connectionObject

User connection status



47
48
49
# File 'lib/rocket_chat/user.rb', line 47

def status_connection
  data['statusConnection']
end

#usernameObject

User username



52
53
54
# File 'lib/rocket_chat/user.rb', line 52

def username
  data['username']
end

#utc_offsetObject

User UTC offset



57
58
59
# File 'lib/rocket_chat/user.rb', line 57

def utc_offset
  data['utcOffset']
end