Tube/Status

A simple MIT licensed Ruby library to access the status of the London Underground network as displayed on the Transport for London Live travel news page.

Installation

$ gem install tube

Examples

require 'tube/status'

status = Tube::Status.new

broken_lines = status.lines.select {|line| line.problem?}
broken_lines.collect {|line| line.name}
#=> ["Circle", "District", "Jubilee", "Metropolitan", "Northern"]

status.lines.detect {|line| line.id == :circle}.message
#=> "Saturday 7 and Sunday 8 March, suspended."

closed_stations = status.station_groups["Closed stations"]
closed_stations.collect {|station| station.name}
#=> ["Blackfriars", "Hatton Cross"]

stations = status.station_groups.values.flatten
stations.detect {|station| station.name =~ "hatton"}.message
#=> "Saturday 7 and Sunday 8 March, closed."

status.updated.strftime("%I:%M%p")
#=> "04:56PM"

status.reload
status.updated.strftime("%I:%M%p")
#=> "05:00PM"

See the documentation for more details.