Class: Integer

Inherits:
Object show all
Defined in:
lib/core_ext/integer.rb

Instance Method Summary collapse

Instance Method Details

#commaString

Returns comma-split String

Examples:

10000.comma   # => "10,000"
1.comma       # => "1"
-100000.comma # => "-100,000"

Returns:


8
9
10
# File 'lib/core_ext/integer.rb', line 8

def comma
  to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse
end