Class: Charisma::NumberHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/charisma/number_helper.rb

Overview

Various methods for dealing with numbers

Class Method Summary collapse

Class Method Details

.delimit(number) ⇒ String

Delimit a number with commas and return as a string.

Adapted from ActionView.

Parameters:

  • number (Fixnum)

    The number to delimit

Returns:

  • (String)


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