Sha256: 0e764ec0e851f193d4d984f249024ae54b893aaa581c1d5615aa006951bb02a5
Contents?: true
Size: 506 Bytes
Versions: 8
Compression:
Stored size: 506 Bytes
Contents
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 return str end end
Version data entries
8 entries across 8 versions & 1 rubygems