Module: Weese::Rail::RequiresStation

Includes:
Weese::Requests::Requester
Included in:
MetroRail
Defined in:
lib/weese/rail/station.rb

Overview

These requests require a Station

Instance Method Summary collapse

Methods included from Weese::Requests::Requester

#fetch, #request

Instance Method Details

#elevator_and_escalator_incidents(station = nil) ⇒ Hash

List of reported elevator and escalator outages at a given station. WMATA Documentation

Parameters:

  • station (String) (defaults to: nil)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/weese/rail/station.rb', line 145

def elevator_and_escalator_incidents(station = nil)
  query = station ? { StationCode: station } : {}

  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::ELEVATOR_AND_ESCALATOR_INCIDENTS,
      query
    )
  )
end

#incidents(station = nil) ⇒ Hash

Reported rail incidents (significant disruptions and delays to normal service) WMATA Documentation

Parameters:

  • station (String) (defaults to: nil)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/weese/rail/station.rb', line 167

def incidents(station = nil)
  query = station ? { StationCode: station } : {}

  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::INCIDENTS,
      query
    )
  )
end

#next_trains(station) ⇒ Hash

Next train arrivals for the given station. WMATA Documentation

Parameters:

  • station (String)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



189
190
191
192
193
194
195
196
197
# File 'lib/weese/rail/station.rb', line 189

def next_trains(station)
  fetch(
    Requests::Request.new(
      @api_key,
      [Rail::Urls::NEXT_TRAINS, station].join('/'),
      {}
    )
  )
end

#parking_information(station) ⇒ Hash

Parking information for the given station. WMATA Documentation

Parameters:

  • station (String)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



229
230
231
232
233
234
235
236
237
# File 'lib/weese/rail/station.rb', line 229

def parking_information(station)
  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::PARKING_INFORMATION,
      StationCode: station
    )
  )
end

#path_from(station, to_destination_station) ⇒ Hash

Stations and distances between two stations on the same line. WMATA Documentation

Parameters:

  • station (String)

    Starting station code

  • to_destination_station (String)

    Destination station code

Returns:

  • (Hash)

    JSON Response

Raises:



250
251
252
253
254
255
256
257
258
259
# File 'lib/weese/rail/station.rb', line 250

def path_from(station, to_destination_station)
  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::PATH,
      FromStationCode: station,
      ToStationCode: to_destination_station
    )
  )
end

#station_information(station) ⇒ Hash

Location and address information at the given station. WMATA Documentation

Parameters:

  • station (String)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



209
210
211
212
213
214
215
216
217
# File 'lib/weese/rail/station.rb', line 209

def station_information(station)
  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::INFORMATION,
      StationCode: station
    )
  )
end

#station_to_station(from_station = nil, to_destination_station = nil) ⇒ Hash

Distance, fare information, and estimated travel time between any two stations, including those on different lines. WMATA Documentation

Parameters:

  • from_station (String) (defaults to: nil)

    Station code to start trip at. Optional.

  • to_destination_station (String) (defaults to: nil)

    Destination station code. Optional.

Returns:

  • (Hash)

    JSON Response

Raises:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/weese/rail/station.rb', line 119

def station_to_station(from_station = nil, to_destination_station = nil)
  query = {}

  query['FromStationCode'] = from_station if from_station

  query['ToStationCode'] = to_destination_station if to_destination_station

  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::STATION_TO_STATION,
      query
    )
  )
end

#timings(station) ⇒ Hash

Opening and scheduled first/last train times for the given station. WMATA Documentation

Parameters:

  • station (String)

    A station code

Returns:

  • (Hash)

    JSON Response

Raises:



271
272
273
274
275
276
277
278
279
# File 'lib/weese/rail/station.rb', line 271

def timings(station)
  fetch(
    Requests::Request.new(
      @api_key,
      Rail::Urls::TIMINGS,
      StationCode: station
    )
  )
end