lib/farecalculator.rb
##
#
# Yuck, this is way to complicated, refactor it!
#
Yuck, this is way to complicated, refactor it!
Yuck this is way to complicated refactor it!
def selectZoneToMatch(startLocation, endLocation)
      if(startLocation.hasZones())
        startZone, endZone = findMinimalZoneDifference(startLocation, endLocation)
        startFareTable = getFareTable(startZone)
        endFareTable = getFareTable(endZone)
        if startFareTable == nil && endFareTable == nil
          @@log.debug('No fare tables for either start or end')
          startLocation.defaultZone()
        else
          @@log.debug('Tables exist for one or both')
          if startFareTable != nil && endFareTable != nil
            (startZone < endZone) ? startZone : endZone
          else
            (startFareTable!=nil) ? startZone : endZone
          end
        end
      else
        startLocation.defaultZone()
      end
    end
def selectZoneToMatch ( startLocation , endLocation ) if ( startLocation . hasZones ( ) ) startZone , endZone = findMinimalZoneDifference ( startLocation , endLocation ) startFareTable = getFareTable ( startZone ) endFareTable = getFareTable ( endZone ) if startFareTable == nil && endFareTable == nil @@log . debug ( 'No fare tables for either start or end' ) startLocation . defaultZone ( ) else @@log . debug ( 'Tables exist for one or both' ) if startFareTable != nil && endFareTable != nil ( startZone < endZone ) ? startZone : endZone else ( startFareTable != nil ) ? startZone : endZone end end else startLocation . defaultZone ( ) end end
Yuck, this is way to complicated, refactor it!
Yuck this is way to complicated refactor it!
startLocation
<not_specific>
endLocation
<not_specific>