Last active
August 29, 2015 14:05
-
-
Save yannvery/4b6c1ea6f20725a3b2d6 to your computer and use it in GitHub Desktop.
Rails helper to abbrev number
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 abbrev_number(number,decimal) | |
| l=number.to_s.length - 1 | |
| "%.#{decimal}f%s"%[number.to_f/10**(l-l%3)," kMGTPE"[l/3]] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment