Class: Integer
Instance Method Summary collapse
Instance Method Details
#to_readable(convert) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yandex_disk/ext.rb', line 15 def to_readable(convert) return self unless convert conv = {'Byte' => 1024, 'KB' => 1024**2, 'MB' => 1024**3, 'GB' => 1024**4} conv.each do |suf, size| next if self >= size return "%.2f %s" % [ self / (size / 1024).to_f, suf ] end end |