octranspo_fetch 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/octranspo_fetch.rb +8 -3
- metadata +1 -1
data/lib/octranspo_fetch.rb
CHANGED
@@ -117,14 +117,18 @@ class OCTranspo
|
|
117
117
|
time_delta = Time.now.to_i - trips[:time]
|
118
118
|
route_obj[:request_processing_time] += time_delta
|
119
119
|
route_obj[:trips] = deep_copy(trips[:trips])
|
120
|
-
route_obj[:trips].each do |trip|
|
121
120
|
route_obj[:cached] = true
|
122
|
-
|
121
|
+
route_obj[:trips].each do |trip|
|
122
|
+
trip[:adjusted_schedule_time] -= (time_delta.to_f / 60).round
|
123
123
|
if trip[:adjustment_age] > 0
|
124
124
|
trip[:adjustment_age] += time_delta.to_f / 60
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
# Filter out results with negative arrival times, since they've probably
|
129
|
+
# already gone by.
|
130
|
+
route_obj[:trips].select! { |trip| trip[:adjusted_schedule_time] >= 0 }
|
131
|
+
|
128
132
|
else
|
129
133
|
# No data in the cache... Hrm...
|
130
134
|
end
|
@@ -148,7 +152,8 @@ class OCTranspo
|
|
148
152
|
# `{stop, stop_description, route_no, route_label, direction, arrival_in_minutes, ...}` objects.
|
149
153
|
#
|
150
154
|
# `...` is any data that would be available from a `trip` object from
|
151
|
-
# `get_next_trips_for_stop()` (e.g. gps_speed, latitude, longitude, etc...)
|
155
|
+
# `get_next_trips_for_stop()` (e.g. gps_speed, latitude, longitude, etc...) Returned results
|
156
|
+
# are sorted in ascending arrival time.
|
152
157
|
#
|
153
158
|
# Arguments:
|
154
159
|
# stop: (String) The stop number.
|