Class: Poundie::Campfire::User

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ User

Returns a new instance of User.



15
16
17
# File 'lib/poundie/campfire/user.rb', line 15

def initialize(hash)
  @hash = hash
end

Class Method Details

.cache ⇒ Object



11
12
13
# File 'lib/poundie/campfire/user.rb', line 11

def self.cache
  @cache ||= {}
end

.get(room, user_id) ⇒ Object



4
5
6
7
8
9
# File 'lib/poundie/campfire/user.rb', line 4

def self.get(room, user_id)
  cache[user_id] || begin
    json = room.users.detect { |u| u["id"] == user_id }
    cache[user_id] = Poundie::Campfire::User.new(json)
  end
end

Instance Method Details

#admin? ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/poundie/campfire/user.rb', line 31

def admin?
  @hash[:admin]
end

#created_at ⇒ Object



35
36
37
# File 'lib/poundie/campfire/user.rb', line 35

def created_at
  @hash[:admin]
end

#email_address ⇒ Object



27
28
29
# File 'lib/poundie/campfire/user.rb', line 27

def email_address
  @hash[:email_address]
end

#id ⇒ Object



19
20
21
# File 'lib/poundie/campfire/user.rb', line 19

def id
  @hash[:id]
end

#name ⇒ Object



23
24
25
# File 'lib/poundie/campfire/user.rb', line 23

def name
  @hash[:name]
end

#type ⇒ Object



39
40
41
# File 'lib/poundie/campfire/user.rb', line 39

def type
  @hash[:type]
end