diff options
| author | Teddy Wing | 2017-05-24 11:41:22 +0200 |
|---|---|---|
| committer | Robert | 2017-05-29 08:49:52 +0200 |
| commit | 8b9d4a03548b6fd8783e596974a51383d7e17c57 (patch) | |
| tree | 5332443b8859cbb83a9da9fe7a7467f183b2ea64 | |
| parent | 278fb14a2dfedef96682a3be3d106d7d451ca483 (diff) | |
| download | chouette-core-8b9d4a03548b6fd8783e596974a51383d7e17c57.tar.bz2 | |
IncreasingTimeOrderValidator: Rename `result` to `valid`
Make it more obvious what the return value is.
Also add some extra whitespace.
Refs #870
| -rw-r--r-- | app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb b/app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb index cc32ae520..a08ca42ea 100644 --- a/app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb +++ b/app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb @@ -24,18 +24,20 @@ module Chouette end def self.increasing_times_validate(at_stop, previous_at_stop) - result = true - return result unless previous_at_stop + valid = true + return valid unless previous_at_stop if self.exceeds_gap?(previous_at_stop.departure_time, at_stop.departure_time) - result = false + valid = false at_stop.errors.add(:departure_time, 'departure time gap overflow') end + if self.exceeds_gap?(previous_at_stop.arrival_time, at_stop.arrival_time) - result = false + valid = false at_stop.errors.add(:arrival_time, 'arrival time gap overflow') end - result + + valid end # TODO: Get rid of this and change to TimeDuration version |
