Class: TrainStop

Inherits:
Object
  • Object
show all
Defined in:
lib/viaggiatreno/train_stop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(train_station, scheduled_stop_time, actual_stop_time, status) ⇒ TrainStop

Returns a new instance of TrainStop.



6
7
8
9
10
11
# File 'lib/viaggiatreno/train_stop.rb', line 6

def initialize(train_station, scheduled_stop_time, actual_stop_time, status)
  @train_station = train_station
  @scheduled_stop_time = scheduled_stop_time
  @actual_stop_time = actual_stop_time
  @status = status
end

Instance Attribute Details

#actual_stop_timeObject

Returns the value of attribute actual_stop_time.



4
5
6
# File 'lib/viaggiatreno/train_stop.rb', line 4

def actual_stop_time
  @actual_stop_time
end

#scheduled_stop_timeObject

Returns the value of attribute scheduled_stop_time.



4
5
6
# File 'lib/viaggiatreno/train_stop.rb', line 4

def scheduled_stop_time
  @scheduled_stop_time
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/viaggiatreno/train_stop.rb', line 4

def status
  @status
end

#train_stationObject

Returns the value of attribute train_station.



4
5
6
# File 'lib/viaggiatreno/train_stop.rb', line 4

def train_station
  @train_station
end

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/viaggiatreno/train_stop.rb', line 13

def to_s
  retstr = ''
  if @status == TrainStopState::DONE
    done = 'X'
    actual_or_expected = 'ACTUAL'
  elsif @status == TrainStopState::TO_BE_DONE
    done = ' '
    actual_or_expected = 'EXPECTED'
  end
  retstr += "[#{done}] #{train_station} = SCHEDULED: #{scheduled_stop_time}"\
            " #{actual_or_expected}: #{actual_stop_time}"
  retstr
end