Class: Operationcode::Slack::User
- Inherits:
-
Object
- Object
- Operationcode::Slack::User
- Defined in:
- lib/operationcode/slack/user.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(data) ⇒ User
constructor
A new instance of User.
- #populate_name! ⇒ Object
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/operationcode/slack/user.rb', line 6 def initialize(data) # If we get a string should we go look the users info up? if data.is_a? String @id = data populate_name! else @id = data['id'] @name = data['name'] end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/operationcode/slack/user.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/operationcode/slack/user.rb', line 4 def name @name end |
Instance Method Details
#populate_name! ⇒ Object
17 18 19 20 |
# File 'lib/operationcode/slack/user.rb', line 17 def populate_name! res = Operationcode::Slack::Api::UsersInfo.post(with_data: { user: @id }) @name = res['user']['real_name'] if res['user'] end |