diff options
| author | Teddy Wing | 2017-05-30 23:30:48 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-05-31 17:57:36 +0200 |
| commit | 52531e2910b3db6ac2a7c5fedbc14b0be54782dc (patch) | |
| tree | e5148ef532ff5dd3b2e227861f3e50381e8d5d18 /lib/sql | |
| parent | d22ee707c026a71dac64da792cb22f46a1a1dbde (diff) | |
| download | chouette-core-52531e2910b3db6ac2a7c5fedbc14b0be54782dc.tar.bz2 | |
VehicleJourneyAtStopsDayOffset#calculate!: Adjust loop
Didn't like my code from before so wanted to go back over it. Ultimately
this is pretty much the same though. Still not super happy, but this
seems to hopefully be a bit better.
Get rid of my first stab at the problem (commented code), as this wasn't
even relevant when I first committed it.
Another idea I was thinking of could be this instead of the `<`
comparisons:
stop.arrival_time.earlier_than(prior_stop.departure_time)
That seems more readable than the standard comparison operator, but
wouldn't look good in terms of implementation. No monkeypatching, but
we'd have to create a new class that has an `#earlier_than` method. Not
ideal. Instead of getting fancy, just left the comparison conditions
pretty much the same as before.
The only change here to the comparisons is to make them a bit more
consistent in terms of ordering and placement.
Instead of using `#each_with_index` and a rotating "previous" variable,
use the `#inject` method to do the loop and give us the previous at-stop
to compare against. A little worried that this is less readable than the
old code, but it feels a touch nicer.
Not ideal perhaps, but good enough I think.
Refs #3596
Diffstat (limited to 'lib/sql')
0 files changed, 0 insertions, 0 deletions
