Class: RouteC::Lights

Inherits:
Object
  • Object
show all
Defined in:
lib/route_c/lights.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.buttonObject



31
32
33
# File 'lib/route_c/lights.rb', line 31

def self.button
  YAML.load_file('config/pins.yaml')['button']
end

.pinsObject



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

#lightsObject



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

#releaseObject



23
24
25
# File 'lib/route_c/lights.rb', line 23

def release
  lights.map { |l| l.release }
end

#turn_onObject



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