Sha256: 0031308409d27c84fb2bf76d4ad8cb51fcd1a255e0a49ba807858d9682473b08
Contents?: true
Size: 421 Bytes
Versions: 4
Compression:
Stored size: 421 Bytes
Contents
module Kernel def human_readable_time(time) hrs = time / 3600 min = (time / 60) % 60 sec = time % 60 "%02i:%02i:%02i" % [hrs, min, sec] end def human_readable_size(size, digits: 1) order = ['B', 'kB', 'MB', 'GB'] magnitude = if size > 0 Integer(Math.log2(size) / 10) else 0 end "%.#{digits}f#{order[magnitude]}" % [Float(size) / (1024 ** magnitude)] end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
snapsync-0.5.0 | lib/snapsync/util.rb |
snapsync-0.4.2 | lib/snapsync/util.rb |
snapsync-0.4.1 | lib/snapsync/util.rb |
snapsync-0.4.0 | lib/snapsync/util.rb |