Class: Weese::Bus::MetroBus
- Inherits:
-
Object
- Object
- Weese::Bus::MetroBus
- Includes:
- RequiresRoute, RequiresStop, Requests::Requester
- Defined in:
- lib/weese/bus/metro_bus.rb
Overview
MetroBus client. Used for accessing MetroBus-related WMATA APIs.
Instance Attribute Summary collapse
-
#api_key ⇒ String
WMATA API key.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ MetroBus
constructor
MetroBus client.
-
#routes ⇒ Hash
List of all bus route variants.
-
#stops(radius_at_coordinates = nil) ⇒ Hash
Nearby bus stops based on latitude, longitude, and radius.
Methods included from RequiresRoute
#incidents, #path, #positions, #route_schedule
Methods included from Requests::Requester
Methods included from RequiresStop
Constructor Details
#initialize(api_key) ⇒ MetroBus
MetroBus client. Used for accessing MetroBus related endpoints
23 24 25 |
# File 'lib/weese/bus/metro_bus.rb', line 23 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ String
Returns WMATA API key.
16 17 18 |
# File 'lib/weese/bus/metro_bus.rb', line 16 def api_key @api_key end |
Instance Method Details
#routes ⇒ Hash
List of all bus route variants. WMATA Documentation
35 36 37 38 39 40 41 42 43 |
# File 'lib/weese/bus/metro_bus.rb', line 35 def routes fetch( Requests::Request.new( @api_key, Bus::Urls::ROUTES, {} ) ) end |
#stops(radius_at_coordinates = nil) ⇒ Hash
Nearby bus stops based on latitude, longitude, and radius. WMATA Documentation
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/weese/bus/metro_bus.rb', line 55 def stops(radius_at_coordinates = nil) query = radius_at_coordinates ? radius_at_coordinates.to_h : {} fetch( Requests::Request.new( @api_key, Bus::Urls::STOPS, query ) ) end |