Class: WMATA::PathSegment

Inherits:
Resource show all
Defined in:
lib/resources/path_segment.rb

Overview

A resource class representing a segment in a path between two stations.

Available attribute methods:

  • station_code - The ID code for an individual station.

  • station_name - The name of the Station.

  • line_code - The ID (color) of the Line associated with the path.

  • seq_num - The sequence of the station in the path.

  • distance_to_previous - Distance in feet from the previous station in the path.

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

#distance_to_previousObject

The distance to the previous station in the path.



33
34
35
# File 'lib/resources/path_segment.rb', line 33

def distance_to_previous
  @attrs['DistanceToPrev']
end

#indexObject

The position this PathSegment is in the overall path.



28
29
30
# File 'lib/resources/path_segment.rb', line 28

def index
  @attrs['SeqNum']
end

#lineObject

Returns the Line instance for the line this segment falls on.



23
24
25
# File 'lib/resources/path_segment.rb', line 23

def line
  @line ||= Line.get(@attrs['LineCode'])
end

#stationObject

Return the Station instance representing the station on this segment of the path.



18
19
20
# File 'lib/resources/path_segment.rb', line 18

def station
  @station ||= Station.get(@attrs['StationCode'])
end