Class: CheekyDreams::Effects::LightShow

Inherits:
Effect
  • Object
show all
Defined in:
lib/cheeky-dreams.rb

Constant Summary

Constants included from CheekyDreams

COLOURS

Instance Method Summary collapse

Methods included from CheekyDreams

#ansi_driver, #audit_to, #crazy, #cycle, #dev_null, #fade, #fade_to, #find_dream_cheeky_usb_device, #forward, #func, #light_show, #max, #off, #position_between, #rgb, #rgb_between, #sleep_until, #solid, #stdio_audit, #stdout_driver, #suppress_duplicates, #throb, #throbbing

Constructor Details

#initialize(effects) ⇒ LightShow

Returns a new instance of LightShow.



238
239
240
# File 'lib/cheeky-dreams.rb', line 238

def initialize effects
  @effects, @current_effect = effects, nil
end

Instance Method Details

#next(current_colour = nil) ⇒ Object



242
243
244
245
246
247
248
249
250
# File 'lib/cheeky-dreams.rb', line 242

def next current_colour = nil
  @current_effect = @effects.delete_at(0) unless @current_effect
  colour, freq = @current_effect.next current_colour
  if (freq == 0 && !@effects.empty?)
    @current_effect = @effects.delete_at(0)
    freq = 100
  end
  [colour, freq]
end