Sha256: 382357c901e23fd509b79fd6d8deafbe4cc7fbc11fd9e2aed632d4b9e23c4469

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'commander/import'
#require 'one_bus_away'
require_relative '../lib/one_bus_away'

program :version, '0.0.1'
program :description, 'Simple querying of One Bus Away'

# puts $LOAD_PATH
@one_bus_away = OneBusAway.new(File.read(ENV['HOME']+"/.one_bus_away"))

command "current-time" do |c|
  c.syntax = 'one-bus-away current-time'
  c.summary = 'Get the current system time from One Bus Away'
  c.description = 'Makes the current_time API call against the One Bus Away API. Simple, Straightforward, Unneeded'
  c.example '','one-bus-away current-time'
  c.action do |args, options|
    puts @one_bus_away.current_time
  end
end

command "arrivals-and-departures-for-stop" do |c|
  c.syntax = 'one-bus-away arrivals-and-departures-for-stop [stop] [route] [arrival time from now]'
  c.summary = 'Next Arrival Time for a specific Stop'
  c.description = 'By default, you can get the next available arrival time.'
  c.example 'description', 'one-bus-away arrivals-and-departures-for-stop [stop] [route] [arrival time from now]'
  c.action do |args, options|
    arrivals = @one_bus_away.arrivals_and_departures_for_stop(args[0], args[1], args[2])
    unless arrivals.empty?
      arrivals.each do |arrival|
        puts "The #{args[1]} arrives in #{arrival}"
      end
    else
      puts "No buses in that time constrain"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
one_bus_away-0.0.2 bin/one-bus-away