Class: Weese::Rail::MetroRail
- Inherits:
-
Object
- Object
- Weese::Rail::MetroRail
- Includes:
- RequiresLine, RequiresStation, Weese::Requests::Requester
- Defined in:
- lib/weese/rail/metro_rail.rb
Overview
MetroRail client. Used for accessing MetroRail-related WMATA APIs. See RequiresLine and RequiresStation for all API calls.
Instance Attribute Summary collapse
-
#api_key ⇒ String
WMATA API key.
Instance Method Summary collapse
-
#circuits ⇒ Hash
All track circuits including those on pocket tracks and crossovers.
-
#entrances(radius_at_coordinates) ⇒ Hash
A list of nearby station entrances based on latitude, longitude, and radius (meters).
-
#initialize(api_key) ⇒ MetroRail
constructor
A MetroRail client, used for accessing all MetroRail-related APIs.
-
#lines ⇒ Hash
Basic information on all MetroRail lines.
-
#positions ⇒ Hash
Uniquely identifiable trains in service and what track circuits they currently occupy.
-
#routes ⇒ Hash
Returns an ordered list of mostly revenue (and some lead) track circuits, arranged by line and track number.
Methods included from RequiresLine
Methods included from Weese::Requests::Requester
Methods included from RequiresStation
#elevator_and_escalator_incidents, #incidents, #next_trains, #parking_information, #path_from, #station_information, #station_to_station, #timings
Constructor Details
#initialize(api_key) ⇒ MetroRail
A MetroRail client, used for accessing all MetroRail-related APIs
26 27 28 |
# File 'lib/weese/rail/metro_rail.rb', line 26 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ String
Returns WMATA API key.
19 20 21 |
# File 'lib/weese/rail/metro_rail.rb', line 19 def api_key @api_key end |
Instance Method Details
#circuits ⇒ Hash
All track circuits including those on pocket tracks and crossovers. Each track circuit may include references to its right and left neighbors. WMATA Documentation
112 113 114 115 116 117 118 119 120 |
# File 'lib/weese/rail/metro_rail.rb', line 112 def circuits fetch( Requests::Request.new( @api_key, Rail::Urls::CIRCUITS, contentType: 'json' ) ) end |
#entrances(radius_at_coordinates) ⇒ Hash
A list of nearby station entrances based on latitude, longitude, and radius (meters). WMATA Documentation
58 59 60 61 62 63 64 65 66 |
# File 'lib/weese/rail/metro_rail.rb', line 58 def entrances(radius_at_coordinates) fetch( Requests::Request.new( @api_key, Rail::Urls::ENTRANCES, radius_at_coordinates.to_h ) ) end |
#lines ⇒ Hash
Basic information on all MetroRail lines. WMATA Documentation
38 39 40 41 42 43 44 45 46 |
# File 'lib/weese/rail/metro_rail.rb', line 38 def lines fetch( Requests::Request.new( api_key, Rail::Urls::LINES, {} ) ) end |
#positions ⇒ Hash
Uniquely identifiable trains in service and what track circuits they currently occupy. WMATA Documentation
76 77 78 79 80 81 82 83 84 |
# File 'lib/weese/rail/metro_rail.rb', line 76 def positions fetch( Requests::Request.new( @api_key, Rail::Urls::POSITIONS, contentType: 'json' ) ) end |
#routes ⇒ Hash
Returns an ordered list of mostly revenue (and some lead) track circuits, arranged by line and track number. WMATA Documentation
94 95 96 97 98 99 100 101 102 |
# File 'lib/weese/rail/metro_rail.rb', line 94 def routes fetch( Requests::Request.new( @api_key, Rail::Urls::ROUTES, contentType: 'json' ) ) end |