class RailFeeds::NetworkRail::Schedule::TrainSchedule::Location::Intermediate
A class for holding information about a particular train's particular location
Attributes
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
@!attribute [rw] line
@return [String]
@!attribute [rw] path
@return [String]
@!attribute [rw] scheduled_arrival
@return [String] The scheduled time for arriving at the location.
@!attribute [rw] scheduled_pass
@return [String] The scheduled time for passing the location.
@!attribute [rw] scheduled_departure
@return [String] The sheduled time for departing from the location.
@!attribute [rw] public_arrival
@return [String] The public arrival time (HHMM).
@!attribute [rw] public_departure
@return [String] The public departure time (HHMM).
@!attribute [rw] engineering_allowance
@return [Float] Number of minutes.
@!attribute [rw] pathing_allowance
@return [Float] Number of minutes.
@!attribute [rw] performance_allowance
@return [Float] Number of minutes.
Public Class Methods
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength Initialize a new intermediate location from a CIF file line
# File lib/rail_feeds/network_rail/schedule/train_schedule/location/intermediate.rb, line 46 def self.from_cif(line) fail ArgumentError, "Invalid line:\n#{line}" unless line[0..1].eql?('LI') new( tiploc: line[2..8].strip, tiploc_suffix: line[9].to_i, scheduled_arrival: line[10..14].strip, scheduled_departure: line[15..19].strip, scheduled_pass: line[20..24].strip, public_arrival: line[25..28].strip, public_departure: line[29..32].strip, platform: line[33..35].strip, line: line[36..38].strip, path: line[39..41].strip, activity: line[42..53].strip, engineering_allowance: parse_allowance(line[54..55].strip), pathing_allowance: parse_allowance(line[56..57].strip), performance_allowance: parse_allowance(line[58..59].strip) ) end
# File lib/rail_feeds/network_rail/schedule/train_schedule/location/intermediate.rb, line 37 def initialize(**attributes) attributes.each do |attribute, value| send "#{attribute}=", value end end
Public Instance Methods
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Style/FormatStringToken
# File lib/rail_feeds/network_rail/schedule/train_schedule/location/intermediate.rb, line 72 def to_cif format('%-80.80s', [ 'LI', format('%-7.7s', tiploc), format('%-1.1s', tiploc_suffix), format('%-5.5s', scheduled_arrival), format('%-5.5s', scheduled_departure), format('%-5.5s', scheduled_pass), format('%-4.4s', public_arrival), format('%-4.4s', public_departure), format('%-3.3s', platform), format('%-3.3s', line), format('%-3.3s', path), format('%-12.12s', activity), format('%-2.2s', allowance_cif(engineering_allowance)), format('%-2.2s', allowance_cif(pathing_allowance)), format('%-2.2s', allowance_cif(performance_allowance)) ].join) + "\n" end
rubocop:disable Metrics/MethodLength
# File lib/rail_feeds/network_rail/schedule/train_schedule/location/intermediate.rb, line 96 def to_hash_for_json { location_type: 'LI', record_identity: 'LI', tiploc_code: tiploc, tiploc_instance: tiploc_suffix, arrival: scheduled_arrival, departure: scheduled_departure, pass: scheduled_pass, public_arrival: public_arrival, public_departure: public_departure, platform: platform, line: line, path: path, engineering_allowance: allowance_json(engineering_allowance), pathing_allowance: allowance_json(pathing_allowance), performance_allowance: allowance_json(performance_allowance) } end