lib/cms_scanner/numeric.rb in cms_scanner-0.0.37.9 vs lib/cms_scanner/numeric.rb in cms_scanner-0.0.37.10
- old
+ new
@@ -1,9 +1,9 @@
# 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)
+ 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