Sha256: a10de3ccc69643a66387154e58634f751185191d6fb0be3b0958f8e291149f5e

Contents?: true

Size: 533 Bytes

Versions: 94

Compression:

Stored size: 533 Bytes

Contents

module ActiveSupport
  module NumberHelper
    class NumberToDelimitedConverter < NumberConverter #:nodoc:
      self.validate_float = true

      DELIMITED_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/

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

      private

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

Version data entries

94 entries across 89 versions & 11 rubygems

Version Path
activesupport-4.2.11.3 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.11.2 lib/active_support/number_helper/number_to_delimited_converter.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/number_helper/number_to_delimited_converter.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.11.1 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.11 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.10 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.10.rc1 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.9 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.9.rc2 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.9.rc1 lib/active_support/number_helper/number_to_delimited_converter.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-4.2.8/lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.8 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.8.rc1 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.7.1 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.7 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.1.16 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.1.16.rc1 lib/active_support/number_helper/number_to_delimited_converter.rb
activesupport-4.2.7.rc1 lib/active_support/number_helper/number_to_delimited_converter.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/number_helper/number_to_delimited_converter.rb