-
-
Save kyanny/50cd2e3373273554103be131d3150677 to your computer and use it in GitHub Desktop.
This file contains 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
class Integer | |
def million | |
self * 1_000_000 | |
end | |
def billion | |
self * 1_000_000_000 | |
end | |
def comma | |
self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse | |
end | |
def human | |
self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1_').reverse | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment