Class: LifxToys::Clouds
- Inherits:
-
Object
- Object
- LifxToys::Clouds
- Defined in:
- lib/lifx_toys/clouds.rb
Constant Summary collapse
- MIN_KELVIN =
2500
- MAX_KELVIN =
9000
- MIN_BRIGHTNESS =
10
- MAX_BRIGHTNESS =
100
- CYCLE_TIME =
5.0
Instance Method Summary collapse
-
#initialize ⇒ Clouds
constructor
A new instance of Clouds.
- #random_brightness ⇒ Object
- #random_kelvin ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize ⇒ Clouds
Returns a new instance of Clouds.
13 14 15 |
# File 'lib/lifx_toys/clouds.rb', line 13 def initialize @lights = LifxHttp::LifxLight.get_lights.select{|x| x.connected } end |
Instance Method Details
#random_brightness ⇒ Object
30 31 32 |
# File 'lib/lifx_toys/clouds.rb', line 30 def random_brightness rand(MIN_BRIGHTNESS..MAX_BRIGHTNESS).to_f / 100 end |
#random_kelvin ⇒ Object
26 27 28 |
# File 'lib/lifx_toys/clouds.rb', line 26 def random_kelvin rand(MIN_KELVIN..MAX_KELVIN) end |
#run ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/lifx_toys/clouds.rb', line 17 def run while (true) @lights.each do |light| light.set_color("kelvin:#{random_kelvin} brightness:#{random_brightness}", duration: CYCLE_TIME* 1.5) sleep(CYCLE_TIME/ @lights.count) end end end |