Created
May 14, 2018 12:45
-
-
Save jiphex/07e4990d97bb77a9a6e58cd568a88f9d to your computer and use it in GitHub Desktop.
Harwell campus bus stop live departures for CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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