Class: Formatters::FormatPercent

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FormatPercent

Returns a new instance of FormatPercent.



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

def initialize(options = {})
end

Instance Method Details

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



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

def from(value, options = {})
  number_to_percentage value, options
end

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



15
16
17
18
# File 'lib/formatters/format_percent.rb', line 15

def to(str, options = {})
  return nil if str.nil? or str.empty?
  str.gsub(/[^0-9\.\-]/, '').to_f
end