https://github.com/matsadler/tube
A simple Ruby library to access the status of the London Underground network.
https://github.com/matsadler/tube
Last synced: about 2 months ago
JSON representation
A simple Ruby library to access the status of the London Underground network.
- Host: GitHub
- URL: https://github.com/matsadler/tube
- Owner: matsadler
- Created: 2009-03-07T21:33:30.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2014-04-08T19:07:24.000Z (about 11 years ago)
- Last Synced: 2025-04-11T23:13:15.177Z (about 2 months ago)
- Language: Ruby
- Homepage: http://sourcetagsandcodes.com/codes/tube_status/doc/
- Size: 176 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= Tube/Status
A simple MIT licensed Ruby library to access the status of the London
Underground network as returned by the Transport for London
{API}[http://api.tfl.gov.uk].Before the API was available this library scraped the data from the TFL
website, at the moment the code has been updated to retain mostly the same Ruby
API, while calling the new TFL API, rather than scrape the website. In the
future this library may change to better match what TFL now make available.== 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"