module D12n::Strategy::Default
Public Instance Methods
bigdecimal_to_formatted(internal)
click to toggle source
# File lib/d12n/strategy/default.rb, line 11 def bigdecimal_to_formatted(internal) ActiveSupport::NumberHelper::NumberToDelimitedConverter.convert(internal, {}) end
formatted_to_bigdecimal(formatted)
click to toggle source
must raise ArgumentError when format is invalid
# File lib/d12n/strategy/default.rb, line 7 def formatted_to_bigdecimal(formatted) BigDecimal(formatted.tr(format_delimiter, '').tr(format_separator, '.')) end
Private Instance Methods
format_delimiter()
click to toggle source
seperates the thousands, eg 1,000
# File lib/d12n/strategy/default.rb, line 18 def format_delimiter ::I18n.translate(:'number.format.delimiter') end
format_separator()
click to toggle source
seperates the decimal points, eg 9.95
# File lib/d12n/strategy/default.rb, line 23 def format_separator ::I18n.translate(:'number.format.separator') end