Skip to content

Instantly share code, notes, and snippets.

@Haumer
Created January 27, 2021 12:51
Show Gist options
  • Save Haumer/767fcfe843b8287e88868015092cd56b to your computer and use it in GitHub Desktop.
Save Haumer/767fcfe843b8287e88868015092cd56b to your computer and use it in GitHub Desktop.
require "open-uri"
require "json"
ENDPOINT = "https://api.tfl.gov.uk/line/mode/tube,overground,dlr,tflrail/status"
json_data = open(ENDPOINT).read
JSON.parse(json_data).each do |line|
name = line["name"]
status = line["lineStatuses"].first["statusSeverityDescription"]
puts "#{status} on the #{name}"
unless line["lineStatuses"].first["reason"].nil?
reason = line["lineStatuses"].first["reason"]
puts "The reason is:"
puts "#{reason}"
puts ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment