Module: NoopBackup::Utils
Instance Method Summary collapse
Instance Method Details
#human_size(bytes) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/noop_backup/utils.rb', line 4 def human_size(bytes) units = %w[B KB MB GB TB] size = bytes.to_f i = 0 while size >= 1024 && i < units.size - 1 size /= 1024 i += 1 end format("%.1f %s", size, units[i]) end |