Class: RouteC::CLI

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

Instance Method Summary collapse

Instance Method Details

#lights(station, direction) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/route_c/cli.rb', line 23

def lights station, direction
  routec = RouteC::Query.new station, direction, options[:time]
  if options['console']
    puts routec.to_a.inspect
  else
    routec.to_lights
  end
end

#versionObject



7
8
9
# File 'lib/route_c/cli.rb', line 7

def version
  puts "routec version #{VERSION}"
end

#watchObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/route_c/cli.rb', line 37

def watch
  if options['daemon']
    file = File.new(File.join('/', 'tmp', '.pid'), 'w+')
    file.write(Process.pid)
    file.rewind
    file.close
  end

  print 'Waiting for you to push the button... '
  PiPiper.watch pin: Lights.button do
    RouteC::CLI.new.watching
  end

  PiPiper.wait
end