Class: Campfiyah::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/campfiyah/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#subdomainObject

Returns the value of attribute subdomain.



3
4
5
# File 'lib/campfiyah/account.rb', line 3

def subdomain
  @subdomain
end

#tokenObject

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



18
19
20
# File 'lib/campfiyah/account.rb', line 18

def room_by_id(id)
  rooms.find {|r| r.id.to_i == id.to_i}
end

#room_by_name(name) ⇒ Object



22
23
24
# File 'lib/campfiyah/account.rb', line 22

def room_by_name(name)
  rooms.find {|r| r.name == name}
end

#roomsObject



12
13
14
15
16
# File 'lib/campfiyah/account.rb', line 12

def rooms
  @rooms ||= @adapter.rooms.map do |room|
    Room.from_hash(room, @adapter)
  end.sort { |a,b| a.name <=> b.name }
end