Module: Weese::Bus::RequiresStop

Includes:
Requests::Requester
Included in:
MetroBus
Defined in:
lib/weese/bus/stop.rb

Overview

These requests require a Stop

Instance Method Summary collapse

Methods included from Requests::Requester

#fetch, #request

Instance Method Details

#next_buses(stop) ⇒ Hash

Next bus arrivals at a given stop. WMATA Documentation

Parameters:

  • stop (Stop)

    A Stop

Returns:

  • (Hash)

    JSON Response

Raises:



36
37
38
39
40
41
42
43
44
# File 'lib/weese/bus/stop.rb', line 36

def next_buses(stop)
  fetch(
    Requests::Request.new(
      @api_key,
      Bus::Urls::NEXT_BUSES,
      StopID: stop.id
    )
  )
end

#stop_schedule(stop, date = nil) ⇒ Hash

Buses scheduled at a stop for an optional given date. WMATA Documentation

Parameters:

  • stop (Stop)

    A Stop

  • date (Date) (defaults to: nil)

    An optional Date

Returns:

  • (Hash)

    JSON Response

Raises:



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/weese/bus/stop.rb', line 57

def stop_schedule(stop, date = nil)
  query = { StopID: stop.id }

  query['Date'] = date.to_s if date

  fetch(
    Requests::Request.new(
      @api_key,
      Bus::Urls::STOP_SCHEDULE,
      query
    )
  )
end