Class: RocketChat::User
- Inherits:
-
Object
- Object
- RocketChat::User
- Defined in:
- lib/rocket_chat/user.rb
Overview
Rocket.Chat User
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Raw user data.
Instance Method Summary collapse
-
#active? ⇒ Boolean
User active.
-
#email ⇒ Object
User email.
-
#email_verified? ⇒ Boolean
User email verified.
-
#emails ⇒ Object
User emails.
-
#id ⇒ Object
User ID.
-
#initialize(data) ⇒ User
constructor
A new instance of User.
- #inspect ⇒ Object
-
#name ⇒ Object
User name.
-
#roles ⇒ Object
User roles.
-
#status ⇒ Object
User status.
-
#status_connection ⇒ Object
User connection status.
-
#username ⇒ Object
User username.
-
#utc_offset ⇒ Object
User UTC offset.
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
12 13 14 |
# File 'lib/rocket_chat/user.rb', line 12 def initialize(data) @data = Util.stringify_hash_keys data end |
Instance Attribute Details
#data ⇒ Object (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
62 63 64 |
# File 'lib/rocket_chat/user.rb', line 62 def active? data['active'] end |
#email ⇒ Object
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
37 38 39 |
# File 'lib/rocket_chat/user.rb', line 37 def email_verified? emails.first && emails.first['verified'] end |
#emails ⇒ Object
User emails
27 28 29 |
# File 'lib/rocket_chat/user.rb', line 27 def emails data['emails'] || [] end |
#id ⇒ Object
User ID
17 18 19 |
# File 'lib/rocket_chat/user.rb', line 17 def id data['_id'] end |
#inspect ⇒ Object
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 |
#name ⇒ Object
User name
22 23 24 |
# File 'lib/rocket_chat/user.rb', line 22 def name data['name'] end |
#roles ⇒ Object
User roles
67 68 69 |
# File 'lib/rocket_chat/user.rb', line 67 def roles data['roles'] end |
#status ⇒ Object
User status
42 43 44 |
# File 'lib/rocket_chat/user.rb', line 42 def status data['status'] end |
#status_connection ⇒ Object
User connection status
47 48 49 |
# File 'lib/rocket_chat/user.rb', line 47 def status_connection data['statusConnection'] end |
#username ⇒ Object
User username
52 53 54 |
# File 'lib/rocket_chat/user.rb', line 52 def username data['username'] end |
#utc_offset ⇒ Object
User UTC offset
57 58 59 |
# File 'lib/rocket_chat/user.rb', line 57 def utc_offset data['utcOffset'] end |