class RailFeeds::NetworkRail::Schedule::TrainSchedule::Location
A class for holding information about a particular train's particular location.
Attributes
activity[RW]
@!attribute [rw] tiploc
@return [String] The location where the change occurs.
@!attribute [rw] tiploc_suffix
@return [String]
@!attribute [rw] platform
@return [String]
@!attribute [rw] activity
@return [String]
platform[RW]
@!attribute [rw] tiploc
@return [String] The location where the change occurs.
@!attribute [rw] tiploc_suffix
@return [String]
@!attribute [rw] platform
@return [String]
@!attribute [rw] activity
@return [String]
tiploc[RW]
@!attribute [rw] tiploc
@return [String] The location where the change occurs.
@!attribute [rw] tiploc_suffix
@return [String]
@!attribute [rw] platform
@return [String]
@!attribute [rw] activity
@return [String]
tiploc_suffix[RW]
@!attribute [rw] tiploc
@return [String] The location where the change occurs.
@!attribute [rw] tiploc_suffix
@return [String]
@!attribute [rw] platform
@return [String]
@!attribute [rw] activity
@return [String]
Public Class Methods
from_cif(line)
click to toggle source
Initialize a new location from a CIF file line (will be of the appropriate sub class)
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 26 def self.from_cif(line) case line[0..1] when 'LO' Origin.from_cif line when 'LI' Intermediate.from_cif line when 'LT' Terminating.from_cif line else fail ArgumentError, "Improper line type #{line[0..1]}: #{line}" end end
new()
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 20 def initialize fail 'This class should never be instantiated' end
Private Class Methods
parse_allowance(value)
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 49 def self.parse_allowance(value) half = value[-1].eql?('H') value = value.to_f half ? value + 0.5 : value end
Public Instance Methods
==(other)
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 39 def ==(other) hash == other&.hash end
hash()
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 43 def hash "#{tiploc}-#{tiploc_suffix}" end
Private Instance Methods
allowance_cif(value)
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 56 def allowance_cif(value) i = value.to_i f = value.to_f - i f.eql?(0.5) ? "#{i}H" : i.to_s end
allowance_json(value)
click to toggle source
# File lib/rail_feeds/network_rail/schedule/train_schedule/location.rb, line 62 def allowance_json(value) return nil if value.nil? i = value.to_i f = value.to_f - i f.eql?(0.5) ? "#{i}H" : i.to_s end