Permalink
Browse files

return nil instead of 99.99 for incomplete fare info

  • Loading branch information...
YenTheFirst committed Jun 14, 2011
1 parent 4c0eb47 commit be2a3cda5a97e9469ebba443db1bc9054c00674b
Showing with 5 additions and 4 deletions.
  1. +4 −3 choices.rb
  2. +1 −1 fare.rb
View
@@ -92,9 +92,10 @@ def calculate_transit_by_bing_resource(resource)
end
#puts "got some rides for #{agency}:"
#pp rides
-
- sum += best_fare(rides,fares)
- end.to_f
+ fare = best_fare(rides,fares)
+ break nil if fare.nil?
+ sum += fare
+ end
{
:duration=>resource["travelDuration"],
View
@@ -53,7 +53,7 @@ def best_fare(rides,fares)
end
#now that we've calculated all the way, we know the optimal cost from start to finish. return it.
- leg_costs[0].last || 99.99 #or something intelligent, if there's no valid fare
+ leg_costs[0].last #if no fare is found, this will just be nil.
end
def best_without_transfers(rides,fares)

0 comments on commit be2a3cd

Please sign in to comment.