aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-05-23 18:11:43 +0200
committerRobert2017-05-29 08:49:52 +0200
commitc8452bfcedf158abf5c10a0ca8d1449650710eca (patch)
tree8053d66466fca9a3df211e2d469844d5a38facab /app
parent3a89c7495894912cfac7b56913ce2465b5314ec6 (diff)
downloadchouette-core-c8452bfcedf158abf5c10a0ca8d1449650710eca.tar.bz2
Move #increasing_times_validate into IncreasingTimeOrderValidator
Just move the methods and tests for now (and add a little whitespace). Haven't modified anything yet so the code isn't working or integrated into the new class. Refs #870
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/vehicle_journey_at_stop.rb18
-rw-r--r--app/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator.rb19
2 files changed, 19 insertions, 18 deletions
diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb
index be69de0ed..cd515be7f 100644
--- a/app/models/chouette/vehicle_journey_at_stop.rb
+++ b/app/models/chouette/vehicle_journey_at_stop.rb
@@ -26,23 +26,5 @@ module Chouette
@_destroy = false
end
- def increasing_times_validate( previous)
- result = true
- return result unless previous
-
- if exceeds_gap?( previous.departure_time, departure_time)
- result = false
- errors.add( :departure_time, 'departure time gap overflow')
- end
- if exceeds_gap?( previous.arrival_time, arrival_time)
- result = false
- errors.add( :arrival_time, 'arrival time gap overflow')
- end
- result
- end
- def exceeds_gap?(earlier, later)
- (4 * 3600) < ((later - earlier) % (3600 * 24))
- end
-
end
end
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 cd43ea953..058bdf79a 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
@@ -23,5 +23,24 @@ module Chouette
previous = vjas
end
end
+
+ def increasing_times_validate( previous)
+ result = true
+ return result unless previous
+
+ if exceeds_gap?( previous.departure_time, departure_time)
+ result = false
+ errors.add( :departure_time, 'departure time gap overflow')
+ end
+ if exceeds_gap?( previous.arrival_time, arrival_time)
+ result = false
+ errors.add( :arrival_time, 'arrival time gap overflow')
+ end
+ result
+ end
+
+ def exceeds_gap?(earlier, later)
+ (4 * 3600) < ((later - earlier) % (3600 * 24))
+ end
end
end