Class: Charisma::NumberHelper
- Inherits:
-
Object
- Object
- Charisma::NumberHelper
- Defined in:
- lib/charisma/number_helper.rb
Overview
Various methods for dealing with numbers
Class Method Summary collapse
-
.delimit(number) ⇒ String
Delimit a number with commas and return as a string.
Class Method Details
.delimit(number) ⇒ String
Delimit a number with commas and return as a string.
Adapted from ActionView.
9 10 11 12 13 |
# File 'lib/charisma/number_helper.rb', line 9 def self.delimit(number) parts = number.to_s.split('.') parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,") parts.join('.') end |