Module: RailFeeds::NetworkRail::Schedule::STPIndicator
- Included in:
- Association, TrainSchedule
- Defined in:
- lib/rail_feeds/network_rail/schedule/stp_indicator.rb
Overview
A collection of methods for working with Short Term Planning indicators. Provides an stp_indicator attribute to the class.
Class Method Summary collapse
Instance Method Summary collapse
-
#stp_indicator ⇒ Symbol?
-
:permanent - This is a permanent (not STP) record * :stp_new - This is a new record (not an overlay) * :stp_overlay - This record should be overlayed on the permanent one * :stp_cancellation - This is an STP cancellation of the permanaent record.
-
-
#stp_indicator=(value) ⇒ Object
-
:permanent, ‘P’ - This is a permanent (not STP) record * :stp_new, ‘N’ - This is a new record (not an overlay) * :stp_overlay, ‘O’ - This record should be overlayed on the permanent one * :stp_cancellation, ‘C’ - This is an STP cancellation of the permanaent record.
-
Class Method Details
.included(base) ⇒ Object
17 18 19 |
# File 'lib/rail_feeds/network_rail/schedule/stp_indicator.rb', line 17 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#stp_indicator ⇒ Symbol?
-
:permanent - This is a permanent (not STP) record
-
:stp_new - This is a new record (not an overlay)
-
:stp_overlay - This record should be overlayed on the permanent one
-
:stp_cancellation - This is an STP cancellation of the permanaent record
26 27 28 |
# File 'lib/rail_feeds/network_rail/schedule/stp_indicator.rb', line 26 def stp_indicator @stp_indicator ||= ' ' end |
#stp_indicator=(value) ⇒ Object
-
:permanent, ‘P’ - This is a permanent (not STP) record
-
:stp_new, ‘N’ - This is a new record (not an overlay)
-
:stp_overlay, ‘O’ - This record should be overlayed on the permanent one
-
:stp_cancellation, ‘C’ - This is an STP cancellation of the permanaent record
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rail_feeds/network_rail/schedule/stp_indicator.rb', line 35 def stp_indicator=(value) if STP_CIF_MAP.map(&:last).include?(value.to_s) # Convert String / to_s value to relevant Symbol value = stp_indicator_from_cif(value) end unless STP_CIF_MAP.map(&:first).include?(value) fail ArgumentError, "value (#{value.inspect}) is invalid, must be any of: " + STP_CIF_MAP.flatten.map(&:inspect).join(', ') end @stp_indicator = value end |