Sha256: 4d5ca044a010429898ed0d0c1d5177a774cfc8f4e96f05143582d291c1d38705

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

#!/usr/bin/env ruby

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

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

if File.exist? ENV['HOME'] + '/.one_bus_away'
  @one_bus_away = OneBusAway.new
else
  fail 'please install your one-bus-away API key into ~/.one_bus_away'
end

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
    @one_bus_away.current_time
    p @one_bus_away.data.entry.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|
    @one_bus_away.arrivals_and_departures_for_stop(
      args[0]
    )

    busses = @one_bus_away.filter_by_route
    if busses.empty?
      puts 'No buses in that time constrain'
    else
      busses.each do |bus|
        puts "The #{bus.keys.first} arrives in #{bus.values.first} minutes"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
one_bus_away-0.0.4 bin/one_bus_away