https://github.com/jish/bart
A Ruby wrapper around the BART API.
https://github.com/jish/bart
Last synced: about 1 year ago
JSON representation
A Ruby wrapper around the BART API.
- Host: GitHub
- URL: https://github.com/jish/bart
- Owner: jish
- Created: 2010-11-13T07:07:13.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2015-07-11T18:32:06.000Z (almost 11 years ago)
- Last Synced: 2025-04-13T03:14:28.676Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 196 KB
- Stars: 9
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A Ruby wrapper around the BART API. [http://api.bart.gov/](http://api.bart.gov/)
[](https://rubygems.org/gems/bart)
## Usage
Create a new station object
```ruby
require 'bart/station'
station = Bart::Station.new(abbr: 'ssan')
station.name
# => "South San Francisco"
```
See when then next trains are supposed to arrive
```ruby
station.load_departures
station.departures.map do |d|
[d.destination.name, d.estimates.map { |e| e.minutes }]
end
# => [["Pittsburg/Bay Point", [5, 25, 50]], ["Millbrae", [5, 25, 46]]]
```
Output a list of upcoming departures:
```ruby
require 'bart'
puts Bart(abbr: :powl).departures
# San Francisco Int'l Airport 2, 22
# Pittsburg/Bay Point 4, 19
```
_NOTE: This is still beta software. All public APIs are subject to change_
### Testing
To run the tests run the `test` Rake task:
$ bundle install
$ bundle exec rake test