Skip to content

Instantly share code, notes, and snippets.

@kyanny

kyanny/.irbrc Secret

Created Dec 25, 2020
Embed
What would you like to do?
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