Module: Storcs::Formatter
- Defined in:
- lib/storcs/formatter.rb
Instance Method Summary collapse
Instance Method Details
#pretty_size(size = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/storcs/formatter.rb', line 3 def pretty_size(size=nil) size ||= self.size units = %w(bytes Kb Mb Gb Tb Pb) i = 0 while size >=1024 && units[i+1] size /= 1024.0 i += 1 end "#{"%.1f" % size}#{units[i]}" end |