Skip to content

Instantly share code, notes, and snippets.

@luki3k5
Created July 31, 2013 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luki3k5/6120586 to your computer and use it in GitHub Desktop.
Save luki3k5/6120586 to your computer and use it in GitHub Desktop.
class CashCounterService
CURRENCIES_BILLS = {
usd: [1, 2, 5, 10, 20, 50, 100],
eur: [1, 2, 5, 10, 20, 50, 100, 200]
}
def calculate_money_received(to_pay, currency=:eur)
to_pay = to_pay.ceil
CURRENCIES_BILLS[currency].each do |bill|
(to_pay / bill).ceil * bill
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment