Class: RubyHue::LightsCollectionState

Inherits:
Object
  • Object
show all
Includes:
RubyHue::Light::BasicState
Defined in:
lib/ruby_hue/lights_collection_state.rb

Constant Summary

Constants included from RubyHue::Light::BasicState

RubyHue::Light::BasicState::IMMUTABLE_KEYS, RubyHue::Light::BasicState::MAPPING

Instance Attribute Summary collapse

Attributes included from RubyHue::Light::BasicState

#state

Instance Method Summary collapse

Methods included from RubyHue::Light::BasicState

#updateable_state

Constructor Details

#initialize(collection) ⇒ LightsCollectionState

Returns a new instance of LightsCollectionState.



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

def initialize(collection)
  @collection = collection
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

Instance Method Details

#bridgeObject



11
12
13
# File 'lib/ruby_hue/lights_collection_state.rb', line 11

def bridge
  collection.bridge
end

#saveObject



15
16
17
18
19
20
21
# File 'lib/ruby_hue/lights_collection_state.rb', line 15

def save
  collection.each do |light|
    url = bridge.resource_url_for("lights/#{light.id}/state")
    body = JSON.generate updateable_state
    Client.put_and_parse(url, body: body)
  end
end