Class: ActiveSupport::NumberHelper::NumberToCurrencyConverter
- Inherits:
-
NumberConverter
- Object
- NumberConverter
- ActiveSupport::NumberHelper::NumberToCurrencyConverter
- Defined in:
- lib/active_support/number_helper/number_to_currency_converter.rb
Overview
:nodoc:
Constant Summary
Constants inherited from NumberConverter
ActiveSupport::NumberHelper::NumberConverter::DEFAULTS
Instance Attribute Summary
Attributes inherited from NumberConverter
Instance Method Summary collapse
Methods inherited from NumberConverter
convert, #execute, #initialize
Constructor Details
This class inherits a constructor from ActiveSupport::NumberHelper::NumberConverter
Instance Method Details
#convert ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_support/number_helper/number_to_currency_converter.rb', line 10 def convert format = [:format] number_f = valid_float? if number_f if number_f.negative? number_f = number_f.abs format = [:negative_format] if (number_f * 10**[:precision]) >= 0.5 end number_s = NumberToRoundedConverter.convert(number_f, ) else number_s = number.to_s.strip format = [:negative_format] if number_s.sub!(/^-/, "") end format.gsub("%n", number_s).gsub("%u", [:unit]) end |