Class: Huebot::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/huebot/bridge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Bridge

Returns a new instance of Bridge.



12
13
14
# File 'lib/huebot/bridge.rb', line 12

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/huebot/bridge.rb', line 10

def client
  @client
end

Class Method Details

.connect(config = Huebot::Config.new) ⇒ Object



3
4
5
6
7
8
# File 'lib/huebot/bridge.rb', line 3

def self.connect(config = Huebot::Config.new)
  client = Client.new(config)
  error = client.connect
  return nil, error if error
  return new(client)
end

Instance Method Details

#groupsObject



20
21
22
# File 'lib/huebot/bridge.rb', line 20

def groups
  client.get!("/groups").map { |(id, attrs)| Group.new(client, id, attrs) }
end

#lightsObject



16
17
18
# File 'lib/huebot/bridge.rb', line 16

def lights
  client.get!("/lights").map { |(id, attrs)| Light.new(client, id, attrs) }
end