Module: L10n::CoreExtensions::NumericExt::ClassMethods
- Defined in:
- lib/l10n/core_extensions/numeric_ext.rb
Instance Method Summary collapse
Instance Method Details
#delocalize(value) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/l10n/core_extensions/numeric_ext.rb', line 6 def delocalize(value) return value unless value.is_a?(String) separator = I18n.t(:'number.format.separator') delimiter = I18n.t(:'number.format.delimiter') value.gsub(delimiter, '').gsub(separator, '.') end |
#localize(value) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/l10n/core_extensions/numeric_ext.rb', line 13 def localize(value) return value unless value.is_a?(Numeric) || value.is_a?(String) separator = I18n.t(:'number.format.separator') delimiter = I18n.t(:'number.format.delimiter') value.to_s.gsub('.', 's').gsub(',', delimiter).gsub('s', separator) end |