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

#log_message(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ellington/line_info.rb', line 17

def log_message(options={})
  message = []
  if options[:line_completed]
    message << "[LINE COMPLETED]"
    message << "[#{line.state(passenger)}]"
    message << "[#{line.name}]"
  end
  if options[:station_completed]
    message << "[STATION COMPLETED]"
    message << "[#{station.state(passenger)}]"
    message << "[#{station_full_name}]"
  end
  line.route.log_options[:passenger].each do |attr|
    message << "[#{attr}:#{passenger.send(attr)}]"
  end
  line.route.log_options[:options].each do |attr|
    message << "[#{attr}:#{self.options[attr]}]"
  end
  message.join " "
end

#station_full_nameObject



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

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