Skip to content

Instantly share code, notes, and snippets.

@JonathonMA
Created July 30, 2013 06:00
Show Gist options
  • Select an option

  • Save JonathonMA/6110583 to your computer and use it in GitHub Desktop.

Select an option

Save JonathonMA/6110583 to your computer and use it in GitHub Desktop.
Money#format is the most complicated thing ever.
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