Sha256: 9eb456443d9714e3c26f80af62e75317bffc6fc25f65f6193ebbf7f1242ea39e
Contents?: true
Size: 650 Bytes
Versions: 2
Compression:
Stored size: 650 Bytes
Contents
module CoreExt 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('.') 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
core_ext-0.0.6 | lib/core_ext/number_helper/number_to_delimited_converter.rb |
core_ext-0.0.5 | lib/core_ext/number_helper/number_to_delimited_converter.rb |