Class: Blufin::Numbers
- Inherits:
-
Object
- Object
- Blufin::Numbers
- Defined in:
- lib/core/numbers.rb
Class Method Summary collapse
-
.add_commas(number) ⇒ Object
Add’s comma’s to numbers greater than 1000.
Class Method Details
.add_commas(number) ⇒ Object
Add’s comma’s to numbers greater than 1000. Code from: dzone.com/articles/format-number-thousands
8 9 10 11 |
# File 'lib/core/numbers.rb', line 8 def self.add_commas(number) whole_part, decimal_part = number.to_s.split('.') [whole_part.gsub(/(\d)(?=\d{3}+$)/, '\1,'), decimal_part].compact.join('.') end |