Class: Slacks::User

Inherits:
Object
  • Object
show all
Defined in:
lib/slacks/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#emailObject (readonly)

Returns the value of attribute email.



3
4
5
# File 'lib/slacks/user.rb', line 3

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



3
4
5
# File 'lib/slacks/user.rb', line 3

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/slacks/user.rb', line 3

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



3
4
5
# File 'lib/slacks/user.rb', line 3

def last_name
  @last_name
end

#usernameObject (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

#inspectObject



20
21
22
# File 'lib/slacks/user.rb', line 20

def inspect
  "<Slacks::User id=\"#{id}\" name=\"#{name}\">"
end

#nameObject



16
17
18
# File 'lib/slacks/user.rb', line 16

def name
  "#{first_name} #{last_name}"
end

#to_sObject



24
25
26
# File 'lib/slacks/user.rb', line 24

def to_s
  "@#{username}"
end