Class: Slacks::User
- Inherits:
-
Object
- Object
- Slacks::User
- Defined in:
- lib/slacks/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(slack, attributes = {}) ⇒ User
constructor
A new instance of User.
- #inspect ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(slack, attributes = {}) ⇒ User
Returns a new instance of User.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/slacks/user.rb', line 5 def initialize(slack, attributes={}) @slack = slack profile = attributes["profile"] @id = attributes["id"] @username = attributes["name"] @email = profile["email"] @first_name = profile["first_name"] @last_name = profile["last_name"] end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/slacks/user.rb', line 3 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
3 4 5 |
# File 'lib/slacks/user.rb', line 3 def first_name @first_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/slacks/user.rb', line 3 def id @id end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
3 4 5 |
# File 'lib/slacks/user.rb', line 3 def last_name @last_name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
3 4 5 |
# File 'lib/slacks/user.rb', line 3 def username @username end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/slacks/user.rb', line 28 def ==(other) self.class == other.class && self.id == other.id end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/slacks/user.rb', line 20 def inspect "<Slacks::User id=\"#{id}\" name=\"#{name}\">" end |
#name ⇒ Object
16 17 18 |
# File 'lib/slacks/user.rb', line 16 def name "#{first_name} #{last_name}" end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/slacks/user.rb', line 24 def to_s "@#{username}" end |