Class: WMATA::Client
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #next_trains(stations = 'A06') ⇒ Object
- #train_incidents ⇒ Object
- #train_path(from, to) ⇒ Object
- #train_stations(line = 'RD', formated = true) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/client.rb', line 7 def initialize(api_key) = {query: {api_key: api_key} } end |
Instance Method Details
#next_trains(stations = 'A06') ⇒ Object
11 12 13 14 |
# File 'lib/client.rb', line 11 def next_trains(stations='A06') response = self.class.get("/StationPrediction.svc/json/GetPrediction/#{stations}", ) JSON.parse(response.body)["Trains"] end |
#train_incidents ⇒ Object
29 30 31 32 |
# File 'lib/client.rb', line 29 def train_incidents response = self.class.get("/Incidents.svc/json/Incidents", ) JSON.parse(response.body)["Incidents"] end |
#train_path(from, to) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/client.rb', line 22 def train_path(from,to) [:query][:FromStationCode] = from [:query][:ToStationCode] = to response = self.class.get("/Rail.svc/json/jPath", ) JSON.parse(response.body)["Path"] end |
#train_stations(line = 'RD', formated = true) ⇒ Object
16 17 18 19 20 |
# File 'lib/client.rb', line 16 def train_stations(line='RD', formated=true) [:query][:LineCode]=line response = self.class.get("/Rail.svc/json/jStations", ) JSON.parse(response.body)["Stations"] end |