octranspo_fetch 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/octranspo_fetch.rb +8 -3
  2. metadata +1 -1
@@ -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
- trip[:adjusted_schedule_time] += (time_delta.to_f / 60).round
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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octranspo_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: