Class: Esbit::Campfire

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subdomain, token) ⇒ Campfire

Returns a new instance of Campfire.



5
6
7
8
9
# File 'lib/esbit/campfire.rb', line 5

def initialize(subdomain, token)
  @subdomain = subdomain
  @token = token
  @connection = Esbit::Connection.new(self)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/esbit/campfire.rb', line 3

def connection
  @connection
end

#subdomainObject (readonly)

Returns the value of attribute subdomain.



3
4
5
# File 'lib/esbit/campfire.rb', line 3

def subdomain
  @subdomain
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/esbit/campfire.rb', line 3

def token
  @token
end

Instance Method Details

#find_room_by_id(room_id) ⇒ Object



21
22
23
# File 'lib/esbit/campfire.rb', line 21

def find_room_by_id(room_id)
  self.rooms.find { |room| room.id == room_id }
end

#find_room_by_name(room_name) ⇒ Object



25
26
27
# File 'lib/esbit/campfire.rb', line 25

def find_room_by_name(room_name)
  self.rooms.find { |room| room.name == room_name }
end

#room(room_id) ⇒ Object



17
18
19
# File 'lib/esbit/campfire.rb', line 17

def room(room_id)
  @connection.get 'rooms', id: room_id
end

#roomsObject



11
12
13
14
15
# File 'lib/esbit/campfire.rb', line 11

def rooms
  @rooms ||= @connection.get('rooms')['rooms'].collect { |room_json|
    Room.new(room_json, @connection)
  }
end