Sha256: d8e3fd018f621809af7420a551ca37b8027f0a507b78136db2c59b08b7c73642
Contents?: true
Size: 318 Bytes
Versions: 28
Compression:
Stored size: 318 Bytes
Contents
# Hack of the Numeric class class Numeric # @return [ String ] A human readable string of the value def bytes_to_human units = %w[B KB MB GB TB] e = abs.zero? ? abs : (Math.log(abs) / Math.log(1024)).floor s = format('%.3f', (abs.to_f / 1024**e)) s.sub(/\.?0*$/, ' ' + units[e]) end end
Version data entries
28 entries across 28 versions & 1 rubygems