Class: ActiveSupport::NumberHelper::NumberToCurrencyConverter
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
NumberConverter
|
|
Instance Chain:
self,
NumberConverter
|
|
Inherits: |
ActiveSupport::NumberHelper::NumberConverter
|
Defined in: | activesupport/lib/active_support/number_helper/number_to_currency_converter.rb |
Constant Summary
NumberConverter
- Inherited
Class Attribute Summary
NumberConverter
- Inherited
Class Method Summary
NumberConverter
- Inherited
Instance Attribute Summary
NumberConverter
- Inherited
Instance Method Summary
- #convert
- #i18n_opts private
- #options private
NumberConverter
- Inherited
Constructor Details
This class inherits a constructor from ActiveSupport::NumberHelper::NumberConverter
Instance Method Details
#convert
[ GitHub ]# File 'activesupport/lib/active_support/number_helper/number_to_currency_converter.rb', line 10
def convert format = [:format] number_d = valid_bigdecimal if number_d if number_d.negative? number_d = number_d.abs format = [:negative_format] if (number_d * 10** [:precision]) >= 0.5 end number_s = NumberToRoundedConverter.convert(number_d, ) else number_s = number.to_s.strip format = [:negative_format] if number_s.sub!(/^-/, "") end format.gsub("%n", number_s).gsub("%u", [:unit]) end
#i18n_opts (private)
[ GitHub ]# File 'activesupport/lib/active_support/number_helper/number_to_currency_converter.rb', line 38
def i18n_opts # Set International negative format if it does not exist i18n = i18n[:negative_format] ||= "-#{i18n[:format]}" if i18n[:format] i18n end
#options (private)
[ GitHub ]# File 'activesupport/lib/active_support/number_helper/number_to_currency_converter.rb', line 29
def @options ||= begin defaults = .merge(i18n_opts) # Override negative format if format options are given defaults[:negative_format] = "-#{opts[:format]}" if opts[:format] defaults.merge!(opts) end end