Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/gruff/patch/string.rb

Constant Summary collapse

THOUSAND_SEPARATOR =
','

Instance Method Summary collapse

Instance Method Details

#commify(delimiter = THOUSAND_SEPARATOR) ⇒ Object



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