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

Version Path
cms_scanner-0.0.41.10 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.9 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.8 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.7 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.6 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.5 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.4 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.3 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.2 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.1 lib/cms_scanner/numeric.rb
cms_scanner-0.0.41.0 lib/cms_scanner/numeric.rb
cms_scanner-0.0.40.3 lib/cms_scanner/numeric.rb
cms_scanner-0.0.40.2 lib/cms_scanner/numeric.rb
cms_scanner-0.0.40.1 lib/cms_scanner/numeric.rb
cms_scanner-0.0.40 lib/cms_scanner/numeric.rb
cms_scanner-0.0.39.4 lib/cms_scanner/numeric.rb
cms_scanner-0.0.39.3 lib/cms_scanner/numeric.rb
cms_scanner-0.0.39.2 lib/cms_scanner/numeric.rb
cms_scanner-0.0.39.1 lib/cms_scanner/numeric.rb
cms_scanner-0.0.39.0 lib/cms_scanner/numeric.rb