Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/server.rb

Instance Method Summary collapse

Instance Method Details

#to_humanObject



90
91
92
93
94
95
96
97
# File 'lib/server.rb', line 90

def to_human
  units = %w{B KB MB GB TB}
  ap self
  e = 0
  e = (Math.log(self)/Math.log(1024)).floor unless self==0
  s = "%.3f" % (to_f / 1024**e)
  s.sub(/\.?0*$/, units[e])
end