aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-05-24 11:52:42 +0200
committerTeddy Wing2017-05-26 13:20:55 +0200
commitf42bb93f9b1189d0d702a4d7776ae2dfa98e2823 (patch)
tree238127dd5a9f68114a6e0e6fe8c07418d4d67ad3 /app
parent6e7bafb1447476b464e87a4e24a07d1162eb6d7c (diff)
downloadchouette-core-f42bb93f9b1189d0d702a4d7776ae2dfa98e2823.tar.bz2
IncreasingTimeOrderValidator: Use `TimeDuration` `exceeds_gap?` method
Get rid of the `.exceeds_gap?` method in this class and standardise on the one that lives in `TimeDuration`. That one takes a duration, so we pass one in when calling the method. (The method is currently set to use a 4 hour duration. We're just reproducing the existing functionality.) Refs #870
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb17
1 files changed, 10 insertions, 7 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 a08ca42ea..1380e48b6 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
@@ -27,22 +27,25 @@ module Chouette
valid = true
return valid unless previous_at_stop
- if self.exceeds_gap?(previous_at_stop.departure_time, at_stop.departure_time)
+ if TimeDuration.exceeds_gap?(
+ 4.hours,
+ previous_at_stop.departure_time,
+ at_stop.departure_time
+ )
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)
+ if TimeDuration.exceeds_gap?(
+ 4.hours,
+ previous_at_stop.arrival_time,
+ at_stop.arrival_time
+ )
valid = false
at_stop.errors.add(:arrival_time, 'arrival time gap overflow')
end
valid
end
-
- # TODO: Get rid of this and change to TimeDuration version
- def self.exceeds_gap?(earlier, later)
- (4 * 3600) < ((later - earlier) % (3600 * 24))
- end
end
end