Class: Lita::Adapters::Slack::SlackUser
- Inherits:
-
Object
- Object
- Lita::Adapters::Slack::SlackUser
- Defined in:
- lib/lita/adapters/slack/slack_user.rb
Overview
A struct representing a Slack user.
Instance Attribute Summary collapse
-
#email ⇒ String
readonly
The user’s email address, e.g.
-
#id ⇒ String
readonly
The user’s unique ID.
-
#metadata ⇒ Hash
(also: #raw_data)
readonly
The raw user data received from Slack, including many more fields.
-
#name ⇒ String
readonly
The user’s mention name, e.g.
-
#real_name ⇒ String
readonly
The user’s display name, e.g.
Class Method Summary collapse
- .from_data(user_data) ⇒ Object private
- .from_data_array(users_data) ⇒ Object private
Instance Method Summary collapse
-
#initialize(id, name, real_name, metadata) ⇒ SlackUser
constructor
A new instance of SlackUser.
Constructor Details
#initialize(id, name, real_name, metadata) ⇒ SlackUser
Returns a new instance of SlackUser.
35 36 37 38 39 40 41 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 35 def initialize(id, name, real_name, ) @id = id @name = name @real_name = real_name.to_s @email = ['email'].to_s @metadata = end |
Instance Attribute Details
#email ⇒ String (readonly)
Returns The user’s email address, e.g. [email protected].
31 32 33 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 31 def email @email end |
#id ⇒ String (readonly)
Returns The user’s unique ID.
25 26 27 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 25 def id @id end |
#metadata ⇒ Hash (readonly) Also known as: raw_data
Returns The raw user data received from Slack, including many more fields.
33 34 35 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 33 def @metadata end |
#name ⇒ String (readonly)
Returns The user’s mention name, e.g. @alice.
27 28 29 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 27 def name @name end |
#real_name ⇒ String (readonly)
Returns The user’s display name, e.g. Alice Bobhart.
29 30 31 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 29 def real_name @real_name end |
Class Method Details
.from_data(user_data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 9 def from_data(user_data) new( user_data['id'], user_data['name'], user_data['real_name'], user_data ) end |
.from_data_array(users_data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/lita/adapters/slack/slack_user.rb', line 19 def from_data_array(users_data) users_data.map { |user_data| from_data(user_data) } end |