Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Created May 18, 2012 05:03
Show Gist options
  • Save DylanLacey/2723260 to your computer and use it in GitHub Desktop.
Save DylanLacey/2723260 to your computer and use it in GitHub Desktop.
Uglyarse code
require "MTDataStone"
class BookingRehydrator
@fleet_map = {
:sydney => :sydney,
:brisbane => nil
}
def self.rehydrate
end
def self.find_fleet (booking)
@fleets = MTDataStone.bookings.get_fleets
find_fleet_for_booking_only(booking) || find_fleet_with_conditions(booking)
end
def self.find_fleet_for_booking_only (booking)
puts "Fleets: #{@fleets}"
fleets_found = @fleets.find_all{ |fleet| fleet.city == @fleet_map[booking.addressed_fleet]}
return fleets_found[0]
end
def self.find_fleet_with_conditions (booking)
conditions = generate_fleet_finding_conditions booking
if booking.addressed_fleet == :brisbane
if conditions == :maxi
found = @fleets.find_all{ |fleet| fleet.city == :maxi}
else
found [email protected]_all{ |fleet| fleet.city == :brisbane}
end
end
return found[0]
end
# Determines what conditions are needed to find an appropriate fleet, EG Maxi may be a different fleet in BNE but not
# Gympie
def self.generate_fleet_finding_conditions (booking)
:maxi if booking.pax > 4
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment