Class: Formatters::FormatInteger

Inherits:
Format show all
Includes:
ActionView::Helpers::NumberHelper
Defined in:
lib/formatters/format_integer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FormatInteger



8
9
# File 'lib/formatters/format_integer.rb', line 8

def initialize(options = {})
end

Instance Method Details

#from(value, options = {}) ⇒ Object



11
12
13
14
# File 'lib/formatters/format_integer.rb', line 11

def from(value, options = {})
  options = {:delimiter => ','}.merge(options)
  number_with_delimiter value, options
end

#to(str, options = {}) ⇒ Object



16
17
18
19
# File 'lib/formatters/format_integer.rb', line 16

def to(str, options = {})
  return nil if str.nil? or str.empty?
  str.gsub(/,/, '').to_i
end