Class: Light

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

Constant Summary

Constants included from CheekyDreams

CheekyDreams::COLOURS

Instance Attribute Summary collapse

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, #position_between, #rgb, #rgb_between, #sleep_until, #solid, #stdio_audit, #stdout_driver, #suppress_duplicates, #throb, #throbbing

Constructor Details

#initialize(driver) ⇒ Light

Returns a new instance of Light.



381
382
383
384
385
# File 'lib/cheeky-dreams.rb', line 381

def initialize driver
  @driver, @auditor, @effect = driver, dev_null, solid(:off)
  @lock, @wake_up = Mutex.new, ConditionVariable.new
  @on = false
end

Instance Attribute Details

#auditorObject

Returns the value of attribute auditor.



377
378
379
# File 'lib/cheeky-dreams.rb', line 377

def auditor
  @auditor
end

#freqObject

Returns the value of attribute freq.



377
378
379
# File 'lib/cheeky-dreams.rb', line 377

def freq
  @freq
end

Instance Method Details

#go(effect) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/cheeky-dreams.rb', line 387

def go effect
  @lock.synchronize {
    case effect
      when Symbol
        @effect = solid(effect)
      when Array
        @effect = solid(effect)
      when CheekyDreams::Effects::Effect
        @effect = effect
      else
        raise "Im sorry dave, I'm afraid I can't do that. #{effect}"
    end
  }
  wakeup
  turn_on unless @on    
end

#offObject



404
405
406
# File 'lib/cheeky-dreams.rb', line 404

def off
  @on = false
end