Class: RubyHue::Light::State

Inherits:
Object
  • Object
show all
Includes:
BasicState
Defined in:
lib/ruby_hue/light/state.rb

Constant Summary

Constants included from BasicState

BasicState::IMMUTABLE_KEYS, BasicState::MAPPING

Instance Attribute Summary collapse

Attributes included from BasicState

#state

Instance Method Summary collapse

Methods included from BasicState

#updateable_state

Constructor Details

#initialize(light, state) ⇒ State

Returns a new instance of State.



9
10
11
12
# File 'lib/ruby_hue/light/state.rb', line 9

def initialize(light, state)
  @light = light
  @state = state
end

Instance Attribute Details

#lightObject (readonly)

Returns the value of attribute light.



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

def light
  @light
end

Instance Method Details

#bridgeObject



20
21
22
# File 'lib/ruby_hue/light/state.rb', line 20

def bridge
  light.bridge
end

#saveObject



14
15
16
17
18
# File 'lib/ruby_hue/light/state.rb', line 14

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