Module: TestProf::MemoryProf::Printer::NumberToHuman
- Defined in:
- lib/test_prof/memory_prof/printer/number_to_human.rb
Constant Summary collapse
- BASE =
1024- UNITS =
%w[B KB MB GB TB PB EB ZB]
Class Method Summary collapse
Class Method Details
.convert(number) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/test_prof/memory_prof/printer/number_to_human.rb', line 11 def convert(number) exponent = exponent(number) human_size = number.to_f / (BASE**exponent) "#{round(human_size)}#{UNITS[exponent]}" end |