Created
September 4, 2014 08:03
-
-
Save ipmsteven/099b8a4b0b0d90fd4446 to your computer and use it in GitHub Desktop.
another ruby regular expression based solution for format_currency
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
| def format_currency(number) | |
| return number if number.blank? | |
| ("%.2f" % number).reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment