Class: RubyHue::Light

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_hue/light.rb,
lib/ruby_hue/light/state.rb,
lib/ruby_hue/light/basic_state.rb

Defined Under Namespace

Modules: BasicState Classes: State

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, bridge) ⇒ Light

Returns a new instance of Light.



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

def initialize(id, bridge)
  @id = id
  @bridge = bridge
end

Instance Attribute Details

#bridgeObject (readonly)

Returns the value of attribute bridge.



3
4
5
# File 'lib/ruby_hue/light.rb', line 3

def bridge
  @bridge
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ruby_hue/light.rb', line 3

def id
  @id
end

Instance Method Details

#attributesObject



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

def attributes
  @attributes ||= Client.get_and_parse bridge.resource_url_for("lights/#{id}")
end

#stateObject



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

def state
  Light::State.new(self, attributes["state"])
end