Skip to content

Instantly share code, notes, and snippets.

@kyanny

kyanny/.irbrc Secret

Created December 25, 2020 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/50cd2e3373273554103be131d3150677 to your computer and use it in GitHub Desktop.
Save kyanny/50cd2e3373273554103be131d3150677 to your computer and use it in GitHub Desktop.
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