Class: SlackBot::User
- Inherits:
-
Object
show all
- Defined in:
- lib/slack/user.rb
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
24
25
26
|
# File 'lib/slack/user.rb', line 24
def initialize(data)
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/slack/user.rb', line 40
def method_missing(sym)
if @data.has_key? sym.to_s
return @data[sym.to_s]
elsif DEFAULT_ATTRS.include? sym.to_sym
return nil
else
super
end
end
|
Instance Method Details
#pretty_first_name ⇒ Object
36
37
38
|
# File 'lib/slack/user.rb', line 36
def pretty_first_name
(real_name && real_name.split(' ').first) || name
end
|
#pretty_name ⇒ Object
32
33
34
|
# File 'lib/slack/user.rb', line 32
def pretty_name
real_name || name
end
|
#to_s ⇒ Object
28
29
30
|
# File 'lib/slack/user.rb', line 28
def to_s
"#{real_name} (#{name})"
end
|