Class: Campfiyah::Account
- Inherits:
-
Object
- Object
- Campfiyah::Account
- Defined in:
- lib/campfiyah/account.rb
Instance Attribute Summary collapse
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(subdomain, token) ⇒ Account
constructor
A new instance of Account.
- #room_by_id(id) ⇒ Object
- #room_by_name(name) ⇒ Object
- #rooms ⇒ Object
- #user_by_id(id) ⇒ Object
Constructor Details
#initialize(subdomain, token) ⇒ Account
Returns a new instance of Account.
5 6 7 8 9 10 |
# File 'lib/campfiyah/account.rb', line 5 def initialize(subdomain, token) @adapter = Campfiyah.adapter.new(subdomain, token) @token = token @subdomain = subdomain end |
Instance Attribute Details
#subdomain ⇒ Object
Returns the value of attribute subdomain.
3 4 5 |
# File 'lib/campfiyah/account.rb', line 3 def subdomain @subdomain end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/campfiyah/account.rb', line 3 def token @token end |
Instance Method Details
#room_by_id(id) ⇒ Object
23 24 25 |
# File 'lib/campfiyah/account.rb', line 23 def room_by_id(id) rooms.find {|r| r.id.to_i == id.to_i} end |
#room_by_name(name) ⇒ Object
27 28 29 |
# File 'lib/campfiyah/account.rb', line 27 def room_by_name(name) rooms.find {|r| r.name == name} end |
#rooms ⇒ Object
17 18 19 20 21 |
# File 'lib/campfiyah/account.rb', line 17 def rooms @rooms ||= @adapter.rooms.map do |room| Room.from_hash(room, @adapter) end.sort { |a,b| a.name <=> b.name } end |
#user_by_id(id) ⇒ Object
12 13 14 15 |
# File 'lib/campfiyah/account.rb', line 12 def user_by_id(id) user = @adapter.user_by_id(id) User.from_hash(user, @adapter) end |