Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/gruff/patch/string.rb
Constant Summary collapse
- THOUSAND_SEPARATOR =
','
Instance Method Summary collapse
-
#commify(delimiter = THOUSAND_SEPARATOR) ⇒ Object
Taken from codesnippets.joyent.com/posts/show/330.
Instance Method Details
#commify(delimiter = THOUSAND_SEPARATOR) ⇒ Object
Taken from codesnippets.joyent.com/posts/show/330
7 8 9 |
# File 'lib/gruff/patch/string.rb', line 7 def commify(delimiter = THOUSAND_SEPARATOR) gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}") end |