Class: ActiveSupport::NumberHelper::NumberToCurrencyConverter
- Inherits:
-
NumberConverter
- Object
- NumberConverter
- ActiveSupport::NumberHelper::NumberToCurrencyConverter
- Defined in:
- activesupport/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 |
# File 'activesupport/lib/active_support/number_helper/number_to_currency_converter.rb', line 10 def convert number = self.number.to_s.strip number_f = number.to_f format = [:format] if number_f.negative? number = number_f.abs unless [:precision] == 0 && number < 0.5 format = [:negative_format] end end rounded_number = NumberToRoundedConverter.convert(number, ) format.gsub("%n", rounded_number).gsub("%u", [:unit]) end |