A ruby gem providing access to the WMATA Rails API on the command line and in a Ruby on Rails application.
Get system wide Rail alerts and arrival and departure times without leaving the console.
gem install dcmetro
$ dcmetro
Commands:
dcmetro alerts
# Display DC Metro system wide alerts.
dcmetro help [COMMAND]
# Describe available commands or one specific command
dcmetro line COLOR
# Display rail lines,
# if COLOR, displays stations on the COLOR line
dcmetro station NAME
# Display station arrival and departure times.
Simplify navigating the WMATA API, merely instantiate a new class and call the methods.
See a live example app, with more details here
class WelcomeController < ApplicationController
def index
dc_metro = DCMetro::Information.new
@alerts = dc_metro.alerts['Incidents']
@lines = dc_metro.line
@stations = dc_metro.line "green"
@college_park = dc_metro.station "college park"
end
%section{:id => "alerts"}
- if @alerts.empty?
%p No incidents to report
- else
- @alerts.each do |alert|
%p= alert['Description']