Sha256: d987667a162f9ce3fa33b5e54e72572d5f6e6c011cac9936091aab76081ca2c2

Contents?: true

Size: 523 Bytes

Versions: 1

Compression:

Stored size: 523 Bytes

Contents

# -*- coding: utf-8 -*-
class Numeric
  #
  # ritorna una stringa con le migliaia serparate da <separator>
  # es.: 100000 -> 1.000.000
  #
  #
  # copiata da http://wiki.rubygarden.org/Ruby/page/show/FixNumFormat
  #
  def with_separator( separator = ',', length = 3 )
    splitter = Regexp.compile "(\\d{#{length}})"
    before, after = self.to_s.split('.')
    before = before.reverse.gsub splitter, '\1' + separator
    str = "#{ before.chomp( separator ).reverse }"
    str += ".#{ after }" if after
    str
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dircat-0.1.5 lib/dircat/extension_numeric.rb