Class: MatrixSdk::User
Overview
A class for tracking information about a user on Matrix
Instance Attribute Summary collapse
- #avatar_url ⇒ Object
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#display_name ⇒ String
The display name.
-
#id ⇒ String
(also: #user_id)
readonly
The MXID of the user.
Instance Method Summary collapse
- #device_keys ⇒ Object
-
#friendly_name ⇒ String
Gets a friendly name of the user.
-
#initialize(client, id, data = {}) ⇒ User
constructor
A new instance of User.
-
#inspect ⇒ String
An inspect method that skips a handful of instance variables to avoid flooding the terminal with debug data.
Constructor Details
#initialize(client, id, data = {}) ⇒ User
Returns a new instance of User.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/matrix_sdk/user.rb', line 21 def initialize(client, id, data = {}) @client = client @id = id @display_name = nil @avatar_url = nil data.each do |k, v| instance_variable_set("@#{k}", v) if instance_variable_defined? "@#{k}" end end |
Instance Attribute Details
#avatar_url ⇒ Object
53 54 55 |
# File 'lib/matrix_sdk/user.rb', line 53 def avatar_url @avatar_url ||= client.api.get_avatar_url(id)[:avatar_url] end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 |
# File 'lib/matrix_sdk/user.rb', line 12 attr_reader :id, :client |
#display_name ⇒ String
Returns the display name.
35 36 37 |
# File 'lib/matrix_sdk/user.rb', line 35 def display_name @display_name ||= client.api.get_display_name(id)[:displayname] end |
#id ⇒ String (readonly) Also known as: user_id
Returns the MXID of the user.
12 13 14 |
# File 'lib/matrix_sdk/user.rb', line 12 def id @id end |
Instance Method Details
#device_keys ⇒ Object
63 64 65 66 67 |
# File 'lib/matrix_sdk/user.rb', line 63 def device_keys @device_keys ||= client.api.keys_query(device_keys: { id => [] }).yield_self do |resp| resp[:device_keys][id.to_sym] end end |
#friendly_name ⇒ String
Gets a friendly name of the user
48 49 50 |
# File 'lib/matrix_sdk/user.rb', line 48 def friendly_name display_name || id end |
#inspect ⇒ String
An inspect method that skips a handful of instance variables to avoid flooding the terminal with debug data.
19 |
# File 'lib/matrix_sdk/user.rb', line 19 ignore_inspect :client |