Class: RailFeeds::NetworkRail::Schedule::TrainSchedule::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/rail_feeds/network_rail/schedule/train_schedule/location.rb,
lib/rail_feeds/network_rail/schedule/train_schedule/location/origin.rb,
lib/rail_feeds/network_rail/schedule/train_schedule/location/terminating.rb,
lib/rail_feeds/network_rail/schedule/train_schedule/location/intermediate.rb

Overview

A class for holding information about a particular train’s particular location.

Direct Known Subclasses

Intermediate, Origin, Terminating

Defined Under Namespace

Classes: Intermediate, Origin, Terminating

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocation

Returns a new instance of Location.



20
21
22
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 20

def initialize
  fail 'This class should never be instantiated'
end

Instance Attribute Details

#activityString

Returns:

  • (String)


18
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 18

attr_accessor :tiploc, :tiploc_suffix, :platform, :activity

#platformString

Returns:

  • (String)


18
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 18

attr_accessor :tiploc, :tiploc_suffix, :platform, :activity

#tiplocString

Returns The location where the change occurs.

Returns:

  • (String)

    The location where the change occurs.



18
19
20
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 18

def tiploc
  @tiploc
end

#tiploc_suffixString

Returns:

  • (String)


18
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 18

attr_accessor :tiploc, :tiploc_suffix, :platform, :activity

Class Method Details

.from_cif(line) ⇒ Object

Initialize a new location from a CIF file line (will be of the appropriate sub class)



26
27
28
29
30
31
32
33
34
35
36
37
# 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

Instance Method Details

#==(other) ⇒ Object



39
40
41
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 39

def ==(other)
  hash == other&.hash
end

#hashObject



43
44
45
# File 'lib/rail_feeds/network_rail/schedule/train_schedule/location.rb', line 43

def hash
  "#{tiploc}-#{tiploc_suffix}"
end