Created
November 24, 2016 15:50
-
-
Save Martin-Nyaga/9d88f2f3a8c2da972d903cbd34d180ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketFactory | |
TICKET_CLASSES = { | |
'Truck' => TruckParkingTicket, | |
'Matatu' => MatatuParkingTicket, | |
'Public Bus' => PublicBusParkingTicket | |
} | |
def self.ticket_for opts | |
# .fetch takes a second argument as a default if the | |
# key is not found | |
TICKET_CLASSES.fetch(opts[:vehicle_type], ParkingTicket).new(opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment