Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/cms_scanner/helper.rb
Overview
Hack of the Numeric class
Instance Method Summary collapse
-
#bytes_to_human ⇒ String
A human readable string of the value.
Instance Method Details
#bytes_to_human ⇒ String
Returns A human readable string of the value.
17 18 19 20 21 22 23 |
# File 'lib/cms_scanner/helper.rb', line 17 def bytes_to_human units = %w(B KB MB GB TB) e = self > 0 ? (Math.log(self) / Math.log(1024)).floor : 0 s = format('%.3f', (to_f / 1024**e)) s.sub(/\.?0*$/, ' ' + units[e]) end |