Module: RubyWasm::SizeFormatter
- Defined in:
- lib/ruby_wasm/util.rb
Class Method Summary collapse
Class Method Details
.format(size) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/ruby_wasm/util.rb', line 3 def format(size) units = %w[B KB MB GB TB] unit = 0 while size > 1024 and unit < units.size - 1 size /= 1024.0 unit += 1 end "%s #{units[unit]}" % size.round(2) end |