Sha256: a37cfc9cc14a2cf9db26b340f8fa3db7a51fec821ff935294043782cafe94b7c

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

module Esbit
  class Campfire
    attr_reader :subdomain, :token, :connection

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
esbit-0.0.4 lib/esbit/campfire.rb
esbit-0.0.3 lib/esbit/campfire.rb