Sha256: e0094105a5d36e21a65cfb59ce387c294cda6ad97f508418d2b4646b85da4b27
Contents?: true
Size: 414 Bytes
Versions: 2
Compression:
Stored size: 414 Bytes
Contents
module WatchmonkeyCli module Helper BYTE_UNITS = %W(TiB GiB MiB KiB B).freeze def human_filesize(s) s = s.to_f i = BYTE_UNITS.length - 1 while s > 512 && i > 0 i -= 1 s /= 1024 end ((s > 9 || s.modulo(1) < 0.1 ? '%d' : '%.1f') % s) + ' ' + BYTE_UNITS[i] end def human_number(n) n.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
watchmonkey_cli-1.6 | lib/watchmonkey_cli/helper.rb |
watchmonkey_cli-1.5 | lib/watchmonkey_cli/helper.rb |