Skip to content

Instantly share code, notes, and snippets.

@sixty4bit
Created August 23, 2009 22:07
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 sixty4bit/173481 to your computer and use it in GitHub Desktop.
Save sixty4bit/173481 to your computer and use it in GitHub Desktop.
class Numeric
# Usage: 1234.commify # => '1,234'
def commify
self.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment