Class: Ellington::LineInfo

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ellington/line_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, station_info) ⇒ LineInfo

Returns a new instance of LineInfo.



7
8
9
10
11
# File 'lib/ellington/line_info.rb', line 7

def initialize(line, station_info)
  @line = line
  @station_info = station_info
  super station_info
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



5
6
7
# File 'lib/ellington/line_info.rb', line 5

def line
  @line
end

#station_infoObject (readonly)

Returns the value of attribute station_info.



5
6
7
# File 'lib/ellington/line_info.rb', line 5

def station_info
  @station_info
end

Instance Method Details

#line_completed_messageObject



26
27
28
29
30
31
32
33
# File 'lib/ellington/line_info.rb', line 26

def line_completed_message
  message = []
  message << "[LINE COMPLETED]"
  message << "[#{line.state(passenger)}]"
  message << "[#{line.name}]"
  message.concat passenger_message
  message.join " "
end

#passenger_messageObject



35
36
37
38
39
40
41
# File 'lib/ellington/line_info.rb', line 35

def passenger_message
  line.route.passenger_attrs_to_log.reduce([]) do |memo, attr|
    value = passenger.send(attr) rescue nil
    memo << "[#{attr}:#{value}]" unless value.nil?
    memo
  end
end

#station_completed_messageObject



17
18
19
20
21
22
23
24
# File 'lib/ellington/line_info.rb', line 17

def station_completed_message
  message = []
  message << "[STATION COMPLETED]"
  message << "[#{station.state(passenger)}]"
  message << "[#{station_full_name}]"
  message.concat passenger_message
  message.join " "
end

#station_full_nameObject



13
14
15
# File 'lib/ellington/line_info.rb', line 13

def station_full_name
  @station_full_name ||= "#{line.route.name} #{line.class.name} #{station.class.name}"
end