Class: WMATA::StationEntrance

Inherits:
Resource
  • Object
show all
Defined in:
lib/resources/station_entrance.rb

Overview

A resource class representing a station entrance (even if it’s just an elevator).

Available attribute methods:

  • id - ID of the entrance.

  • name - The name of the entrance.

  • description - A description of the entrance.

  • lat - The entrance’s latitude.

  • lon - The entrance’s longitude.

Instance Attribute Summary

Attributes inherited from Resource

#attrs

Instance Method Summary collapse

Methods inherited from Resource

endpoint, get_all, #initialize, #method_missing, service, to_query_string

Constructor Details

This class inherits a constructor from WMATA::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class WMATA::Resource

Instance Method Details

#coordinatesObject Also known as: coords



34
35
36
# File 'lib/resources/station_entrance.rb', line 34

def coordinates
  [latitude, longitude]
end

#latitudeObject



26
27
28
# File 'lib/resources/station_entrance.rb', line 26

def latitude
  @attrs['Lat']
end

#longitudeObject



30
31
32
# File 'lib/resources/station_entrance.rb', line 30

def longitude
  @attrs['Lon']
end

#stationObject

Get the Station instance for this entrance.



22
23
24
# File 'lib/resources/station_entrance.rb', line 22

def station
  @station ||= Station.get(station_codes.first)
end

#station_codesObject

Get station codes that this entrance serves.



17
18
19
# File 'lib/resources/station_entrance.rb', line 17

def station_codes
  [@attrs['StationCode1'], @attrs['StationCode2']].compact
end