Created
July 31, 2013 09:11
-
-
Save luki3k5/6120586 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 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