Module: BatchKit::NumericExtensions
- Defined in:
- lib/batch-kit/core_ext/numeric.rb
Instance Method Summary collapse
-
#with_commas ⇒ Object
Converts an integer to a comma-separated string, e.g.
Instance Method Details
#with_commas ⇒ Object
Converts an integer to a comma-separated string, e.g. 1024 becomes “1,024”
6 7 8 |
# File 'lib/batch-kit/core_ext/numeric.rb', line 6 def with_commas self.to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/, "\\1,") end |