Sha256: eb07aef110334e50900cbafc19c6b897096d0f8a028276c11af0eb6b7b8eb43c
Contents?: true
Size: 662 Bytes
Versions: 23
Compression:
Stored size: 662 Bytes
Contents
module ActiveSupport module NumberHelper class NumberToDelimitedConverter < NumberConverter #:nodoc: self.validate_float = true DEFAULT_DELIMITER_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/ def convert parts.join(options[:separator]) end private def parts left, right = number.to_s.split(".".freeze) left.gsub!(delimiter_pattern) do |digit_to_delimit| "#{digit_to_delimit}#{options[:delimiter]}" end [left, right].compact end def delimiter_pattern options.fetch(:delimiter_pattern, DEFAULT_DELIMITER_REGEX) end end end end
Version data entries
23 entries across 23 versions & 3 rubygems