Created
August 4, 2009 08:27
-
-
Save TheNicholasNick/161106 to your computer and use it in GitHub Desktop.
BigDecimal to Money (without the symbol)
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
# all my bigdeciamls going into this have been .round(2) beforehand | |
dollar[1] = dollar[1].split[1] | |
dollar[1] = "#{dollar[1][0, dollar[1].length-2].gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}.#{dollar[1][dollar[1].length-2,2]}" | |
# credit where credit is due, I stole the gsub part from merb numeric helper - thanks merb!! | |
# the rest was bigdecimal docs :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment