Sha256: e37971602eedad744fc815b359a39a548ca67db0abc60573fac8c931e85f9397

Contents?: true

Size: 342 Bytes

Versions: 18

Compression:

Stored size: 342 Bytes

Contents

# frozen_string_literal: true

# @private
module String::GruffCommify
  THOUSAND_SEPARATOR = ','
  private_constant :THOUSAND_SEPARATOR

  refine String do
    # Taken from http://codesnippets.joyent.com/posts/show/330
    def commify(delimiter = THOUSAND_SEPARATOR)
      gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
gruff-0.24.0-java lib/gruff/patch/string.rb
gruff-0.24.0 lib/gruff/patch/string.rb
gruff-0.23.0 lib/gruff/patch/string.rb
gruff-0.23.0-java lib/gruff/patch/string.rb
gruff-0.22.0 lib/gruff/patch/string.rb
gruff-0.22.0-java lib/gruff/patch/string.rb
gruff-0.21.0-java lib/gruff/patch/string.rb
gruff-0.21.0 lib/gruff/patch/string.rb
gruff-0.20.0-java lib/gruff/patch/string.rb
gruff-0.20.0 lib/gruff/patch/string.rb
gruff-0.19.0 lib/gruff/patch/string.rb
gruff-0.19.0-java lib/gruff/patch/string.rb
gruff-0.18.0-java lib/gruff/patch/string.rb
gruff-0.18.0 lib/gruff/patch/string.rb
gruff-0.17.0-java lib/gruff/patch/string.rb
gruff-0.17.0 lib/gruff/patch/string.rb
gruff-0.16.0 lib/gruff/patch/string.rb
gruff-0.16.0-java lib/gruff/patch/string.rb