Class: RubyHue::LightsCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby_hue/lights_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bridge) ⇒ LightsCollection

Returns a new instance of LightsCollection.



7
8
9
# File 'lib/ruby_hue/lights_collection.rb', line 7

def initialize(bridge)
  @bridge = bridge
end

Instance Attribute Details

#bridgeObject (readonly)

Returns the value of attribute bridge.



5
6
7
# File 'lib/ruby_hue/lights_collection.rb', line 5

def bridge
  @bridge
end

Instance Method Details

#each(&block) ⇒ Object



21
22
23
24
25
# File 'lib/ruby_hue/lights_collection.rb', line 21

def each(&block)
  lights.each do |light|
    yield light
  end
end

#lightsObject



11
12
13
14
15
# File 'lib/ruby_hue/lights_collection.rb', line 11

def lights
  Client.get_and_parse(bridge.resource_url_for("lights")).map do |id, light|
    RubyHue::Light.new(id, self)
  end
end

#stateObject



17
18
19
# File 'lib/ruby_hue/lights_collection.rb', line 17

def state
  @state ||= LightsCollectionState.new(self)
end