Sha256: 5bfe22179003421ba7064ec6d7d1dcd71654b2d2ad010cb58f3efd3cad94f8d5

Contents?: true

Size: 318 Bytes

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
cms_scanner-0.0.37.9 lib/cms_scanner/numeric.rb
cms_scanner-0.0.37.8 lib/cms_scanner/numeric.rb
cms_scanner-0.0.37.7 lib/cms_scanner/numeric.rb
cms_scanner-0.0.37.6 lib/cms_scanner/numeric.rb
cms_scanner-0.0.37.5 lib/cms_scanner/numeric.rb