lib/dircat/extension_numeric.rb in dircat-0.1.5 vs lib/dircat/extension_numeric.rb in dircat-0.1.6
- old
+ new
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-
class Numeric
#
- # ritorna una stringa con le migliaia serparate da <separator>
+ # returns a string separated by the thousands <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