Class: Delcom::SignalIndicator
- Inherits:
-
Object
- Object
- Delcom::SignalIndicator
- Defined in:
- lib/delcom_904006.rb
Constant Summary collapse
- FLASH_N =
10
- FLASH_DURATION =
0.3
- COLORS =
{ :off => "\x00", :green => "\x01", :red => "\x02", :yellow => "\x03", :blue => "\x04", :bluegreen => "\x05", :purple => "\x06", :white => "\x07" }
Class Method Summary collapse
Instance Method Summary collapse
- #flash(color, options) ⇒ Object
-
#initialize(device_number = 0) ⇒ SignalIndicator
constructor
A new instance of SignalIndicator.
Constructor Details
#initialize(device_number = 0) ⇒ SignalIndicator
Returns a new instance of SignalIndicator.
37 38 39 |
# File 'lib/delcom_904006.rb', line 37 def initialize(device_number=0) @device = self.class.devices[device_number] end |
Class Method Details
.devices ⇒ Object
31 32 33 34 35 |
# File 'lib/delcom_904006.rb', line 31 def self.devices @devices ||= USB.devices.select {|device| device.idVendor == VENDOR_ID && device.idProduct == PRODUCT_ID}.tap { |devices| raise "Unable to find delcom device(s)" unless devices } end |
Instance Method Details
#flash(color, options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/delcom_904006.rb', line 41 def flash(color, ) p n = [:n] || FLASH_N p duration = [:duration] || FLASH_DURATION (1..n).each { send(color) sleep duration off sleep duration } end |