Created
January 27, 2021 12:51
-
-
Save Haumer/767fcfe843b8287e88868015092cd56b to your computer and use it in GitHub Desktop.
This file contains 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
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