Class: Delocalize::LocalizedNumericParser

Inherits:
Object
  • Object
show all
Defined in:
lib/delocalize/localized_numeric_parser.rb

Class Method Summary collapse

Class Method Details

.parse(value) ⇒ Object

Parse numbers removing unneeded characters and replacing decimal separator through I18n. This will return a valid Ruby Numeric value (as String).



8
9
10
11
12
13
14
15
# File 'lib/delocalize/localized_numeric_parser.rb', line 8

def parse(value)
  if value.is_a?(String)
    separator = I18n.t(:'number.format.separator')
    delimiter = I18n.t(:'number.format.delimiter')
    value = value.gsub(delimiter, '').gsub(separator, '.')
  end
  value
end