Sha256: 71c575a6a30e598cc8c3730b2ecdd5b9a5858785c628f205b997a4c39f901535

Contents?: true

Size: 395 Bytes

Versions: 1

Compression:

Stored size: 395 Bytes

Contents

module Koalemos
  class ::Numeric
    unless method_defined?(:commafy)
      def commaify
        to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
      end
    end
  end
  
  class ::Float
    unless method_defined?(:commafy)
      def commaofy
        to_s.gsub(/\d+\./) do |s|
          s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koalemos-0.0.2 lib/koalemos/commaify.rb