Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created May 14, 2018 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiphex/07e4990d97bb77a9a6e58cd568a88f9d to your computer and use it in GitHub Desktop.
Save jiphex/07e4990d97bb77a9a6e58cd568a88f9d to your computer and use it in GitHub Desktop.
Harwell campus bus stop live departures for CLI
#!/usr/bin/env ruby
require 'net/http'
require 'json'
u = URI('https://fcc.transportapi.com/v3/uk/bus/stop/340000368SHE/live.json?group=no&nextbuses=yes')
res = Net::HTTP.get(u)
b = JSON.load(res)
fs = "%4s %-18s %5s"
h = fs % %w(Bus Towards Time)
puts h
puts "-"*h.length
b["departures"]["all"].each do |dep|
puts fs % [dep["line"],dep["direction"],dep["best_departure_estimate"]]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment