Module: Britebox::Helpers
- Included in:
- FileJobPool
- Defined in:
- lib/britebox/helpers.rb
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#human_size(n) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/britebox/helpers.rb', line 8 def human_size(n) count = 0 while n >= 1024 and count < 4 n /= 1024.0 count += 1 end if count == 0 n.to_s + 'B' else format("%.2f", n) + %w(B KB MB GB TB)[count] end end |