Class: RouteC::Lights
- Inherits:
-
Object
- Object
- RouteC::Lights
- Defined in:
- lib/route_c/lights.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(array) ⇒ Lights
constructor
A new instance of Lights.
- #lights ⇒ Object
- #release ⇒ Object
- #turn_on ⇒ Object
Constructor Details
#initialize(array) ⇒ Lights
Returns a new instance of Lights.
4 5 6 |
# File 'lib/route_c/lights.rb', line 4 def initialize(array) @array = array end |
Class Method Details
.button ⇒ Object
31 32 33 |
# File 'lib/route_c/lights.rb', line 31 def self. YAML.load_file('config/pins.yaml')['button'] end |
.pins ⇒ Object
27 28 29 |
# File 'lib/route_c/lights.rb', line 27 def self.pins YAML.load_file('config/pins.yaml')['lights'] end |
Instance Method Details
#lights ⇒ Object
19 20 21 |
# File 'lib/route_c/lights.rb', line 19 def lights @lights ||= Lights.pins.map { |p| PiPiper::Pin.new(pin: p, direction: :out) } end |
#release ⇒ Object
23 24 25 |
# File 'lib/route_c/lights.rb', line 23 def release lights.map { |l| l.release } end |
#turn_on ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/route_c/lights.rb', line 8 def turn_on @array.each_with_index do |b, i| if b == 1 lights[i].on sleep Query.config['interval'] end end sleep Query.config['pause'] lights.reverse.each { |l| l.off ; sleep Query.config['interval'] } end |