Skip to content

Instantly share code, notes, and snippets.

@rymawby
Created January 19, 2012 15:06
Show Gist options
  • Save rymawby/1640489 to your computer and use it in GitHub Desktop.
Save rymawby/1640489 to your computer and use it in GitHub Desktop.
Real time TFL London Tube updates - Ideal for use as a Geeklet using with GeekTool / NerdTool
require 'rexml/document'
require 'net/http'
include REXML
@location = 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus'
@file = Net::HTTP.get_response(URI.parse(@location))
@xml = REXML::Document.new(@file.body)
@xml.elements.each("ArrayOfLineStatus/LineStatus") do |element|
puts "#{element[3].attribute("Name")} - #{element[5].attribute("Description")}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment