Class: Huemote::Light
- Inherits:
-
Object
- Object
- Huemote::Light
- Defined in:
- lib/huemote/light.rb
Constant Summary collapse
- STATES =
{ brightness: 'bri', saturation: 'sat', effect: 'effect', alert: 'alert', hue: 'hue', xy: 'xy', ct: 'ct' }
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, name) ⇒ Light
constructor
A new instance of Light.
- #off! ⇒ Object
- #off? ⇒ Boolean
- #on! ⇒ Object
- #on? ⇒ Boolean
- #toggle! ⇒ Object
Constructor Details
#initialize(id, name) ⇒ Light
35 36 37 |
# File 'lib/huemote/light.rb', line 35 def initialize(id,name) @id, @name = id, name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
33 34 35 |
# File 'lib/huemote/light.rb', line 33 def name @name end |
Class Method Details
.all(refresh = false) ⇒ Object
16 17 18 19 |
# File 'lib/huemote/light.rb', line 16 def all(refresh=false) @lights = nil if refresh @lights ||= bridge._get('lights').map{|id,h|self.new(id,h['name'])} end |
.find(name) ⇒ Object
21 22 23 |
# File 'lib/huemote/light.rb', line 21 def find(name) all.detect{|l|l.name == name} end |
Instance Method Details
#off! ⇒ Object
43 44 45 |
# File 'lib/huemote/light.rb', line 43 def off! set!(on:false) end |
#off? ⇒ Boolean
51 52 53 |
# File 'lib/huemote/light.rb', line 51 def off? !on? end |
#on! ⇒ Object
39 40 41 |
# File 'lib/huemote/light.rb', line 39 def on! set!(on:true) end |
#on? ⇒ Boolean
47 48 49 |
# File 'lib/huemote/light.rb', line 47 def on? bridge._get("lights/#{@id}")['state']['on'] end |
#toggle! ⇒ Object
55 56 57 |
# File 'lib/huemote/light.rb', line 55 def toggle! on? ? off! : on! end |