Created
July 30, 2013 06:00
-
-
Save JonathonMA/6110583 to your computer and use it in GitHub Desktop.
Money#format is the most complicated thing ever.
This file contains hidden or 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
| module NihMoney | |
| def nih_money_units money | |
| if money.cents % money.currency.subunit_to_unit == 0 | |
| money.cents / money.currency.subunit_to_unit | |
| else | |
| money.cents.to_f / money.currency.subunit_to_unit | |
| end | |
| end | |
| def nih_humanized_money_with_symbol money | |
| "#{money.currency.symbol}#{nih_money_units(money)}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment