Skip to content

Instantly share code, notes, and snippets.

@Martin-Nyaga
Created November 24, 2016 15:46
Show Gist options
  • Save Martin-Nyaga/ee63fe0284621638fb211ad32610883e to your computer and use it in GitHub Desktop.
Save Martin-Nyaga/ee63fe0284621638fb211ad32610883e to your computer and use it in GitHub Desktop.
class ParkingTicket
def initialize(opts)
@day = opts[:day] || raise(":day is required")
@vehicle_type = opts[:vehicle_type] || raise(":vehicle_type is required")
@eet_passed = opts[:eet_passed] || raise(":eet_passed is required")
...
end
def base_fee
1000
end
def total_cost
base_fee + surcharge
end
def surcharge
case @day
when "Monday", "Tuesday", "Wednesday", "Friday"
100
when "Thursday", "Saturday", "Sunday"
150
end
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment