class RouteC::CLI

Public Instance Methods

config() click to toggle source
# File lib/route_c/cli.rb, line 77
def config
  @config ||= Config.new
end
lights(station, direction) click to toggle source
# File lib/route_c/cli.rb, line 23
def lights station, direction
  begin
    routec = RouteC::Query.new station, direction, options[:time]
  rescue RouteCException => rce
    puts rce.status
    exit 1
  end

  if options['console']
    puts routec.to_a.inspect
  else
    routec.to_lights
  end
end
version() click to toggle source
# File lib/route_c/cli.rb, line 7
def version
  puts "routec version #{VERSION}"
end
watch() click to toggle source
# File lib/route_c/cli.rb, line 43
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: config.button do
    RouteC::CLI.new.watching
  end

  PiPiper.wait
end
watching() click to toggle source
# File lib/route_c/cli.rb, line 60
def watching
  puts 'done'
  print 'Getting data... '
  routec = RouteC::Query.new config.station, config.direction
  puts 'done'

  print 'Lighting lights... '
  routec.to_lights
  puts 'done'

  print 'Releasing lights... '
  routec.lights.release
  puts 'done'

  print 'Waiting for you to push the button... '
end