Skip to content

Instantly share code, notes, and snippets.

@pjhyett
Created May 3, 2009 07:47
Show Gist options
  • Save pjhyett/105893 to your computer and use it in GitHub Desktop.
Save pjhyett/105893 to your computer and use it in GitHub Desktop.
class Numeric
def commify
to_s.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
end
end
Numeric.new.commify(500000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment