Class: WMATA::RailIncident
- Defined in:
- lib/resources/rail_incident.rb
Overview
A resource class representing a rail incident (e.g., garbage on the rails delaying a train).
Available attribute methods:
-
incident_id
- ID of the nicident -
incident_type
- Type of the nicident -
date_updated
- Date and time where information was updated. -
delay_severity
- Severity of delay (if any). Can be:minor
,:major
, or:medium
. -
description
- Description what happened. -
emergency_text
- Some text for emergency (if any). -
start_location_full_name
- Station where delay starts. -
end_location_full_name
- Station where delay ends. -
passenger_delay
- Delay in minutes.
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.get_by_line(line) ⇒ Object
Get all rail incidents by the line; can be a line code string or a
Line
instance.
Instance Method Summary collapse
-
#date_updated ⇒ Object
Get a
Time
object representing the last time this API data entry was updated. - #delay_severity ⇒ Object
-
#incident_id ⇒ Object
ID of the incident.
-
#line_codes_affected ⇒ Object
Get an array of the line codes affected by this incident.
-
#lines_affected ⇒ Object
Get
Line
instances for the lines affected by this incident.
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
Class Method Details
.get_by_line(line) ⇒ Object
Get all rail incidents by the line; can be a line code string or a Line
instance.
22 23 24 25 |
# File 'lib/resources/rail_incident.rb', line 22 def self.get_by_line(line) @incidents ||= get_all @incidents.select {|i| i.line_codes_affected.include?(line.to_s)} end |
Instance Method Details
#date_updated ⇒ Object
Get a Time
object representing the last time this API data entry was updated.
29 30 31 |
# File 'lib/resources/rail_incident.rb', line 29 def date_updated Time.parse(@attrs['DateUpdated']) end |
#delay_severity ⇒ Object
48 49 50 |
# File 'lib/resources/rail_incident.rb', line 48 def delay_severity @attrs['DelaySeverity'].to_s.downcase.to_sym end |
#incident_id ⇒ Object
ID of the incident.
44 45 46 |
# File 'lib/resources/rail_incident.rb', line 44 def incident_id @attrs['IncidentID'] end |
#line_codes_affected ⇒ Object
Get an array of the line codes affected by this incident.
34 35 36 |
# File 'lib/resources/rail_incident.rb', line 34 def line_codes_affected @attrs['LinesAffected'].split(";").reject {|s| s.empty? || s.nil?} end |