123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::NumberHelper::NumberToDelimitedConverter

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::NumberHelper::NumberConverter
Defined in: activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb

Constant Summary

NumberConverter - Inherited

DEFAULTS

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

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_delimited_converter.rb', line 12

def convert
  parts.join(options[:separator])
end

#delimiter_pattern (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb', line 25

def delimiter_pattern
  options.fetch(:delimiter_pattern, DEFAULT_DELIMITER_REGEX)
end

#parts (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb', line 17

def parts
  left, right = number.to_s.split(".")
  left.gsub!(delimiter_pattern) do |digit_to_delimit|
    "#{digit_to_delimit}#{options[:delimiter]}"
  end
  [left, right].compact
end