Skip to content

Instantly share code, notes, and snippets.

@Martin-Nyaga
Created November 24, 2016 15:49
Show Gist options
  • Save Martin-Nyaga/de29b83ac93d6dd16e2b7eea366aa599 to your computer and use it in GitHub Desktop.
Save Martin-Nyaga/de29b83ac93d6dd16e2b7eea366aa599 to your computer and use it in GitHub Desktop.
class TicketFactory
def self.ticket_for opts
class_for(opts[:vehicle_type]).new(opts)
end
def self.class_for vehicle_type
case vehicle_type
when 'Truck'
TruckParkingTicket
when 'Matatu'
MatatuParkingTicket
when 'Public Bus'
PublicBusParkingTicket
else
ParkingTicket
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment