Class: Campfiyah::Room
- Inherits:
-
Object
- Object
- Campfiyah::Room
- Defined in:
- lib/campfiyah/room.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(adapter, id, name, updated_at) ⇒ Room
constructor
A new instance of Room.
- #message(message) ⇒ Object
- #users ⇒ Object
- #users! ⇒ Object
Constructor Details
#initialize(adapter, id, name, updated_at) ⇒ Room
Returns a new instance of Room.
4 5 6 |
# File 'lib/campfiyah/room.rb', line 4 def initialize(adapter, id, name, updated_at) @adapter, @id, @name, @updated_at = adapter, id, name, updated_at end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/campfiyah/room.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/campfiyah/room.rb', line 3 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/campfiyah/room.rb', line 3 def updated_at @updated_at end |
Class Method Details
.from_hash(hash, adapter) ⇒ Object
8 9 10 |
# File 'lib/campfiyah/room.rb', line 8 def self.from_hash(hash, adapter) new(adapter, hash["id"], hash["name"], hash["updated_at"]) end |
Instance Method Details
#message(message) ⇒ Object
12 13 14 |
# File 'lib/campfiyah/room.rb', line 12 def () @adapter.(id, ) end |
#users ⇒ Object
16 17 18 |
# File 'lib/campfiyah/room.rb', line 16 def users @users ||= users! end |
#users! ⇒ Object
20 21 22 23 |
# File 'lib/campfiyah/room.rb', line 20 def users! room = @adapter.room_by_id(id) room['users'].map { |user| User.from_hash(user, @adapter) } end |