Sha256: d2bfebbcb6771b455dcd85830156957a3023c39eb5dceb9de95a6862ac243cce
Contents?: true
Size: 273 Bytes
Versions: 5
Compression:
Stored size: 273 Bytes
Contents
class Integer def as_bytes return "1 Byte" if self == 1 label = ["Bytes", "KiB", "MiB", "GiB", "TiB"] i = 0 num = self.to_f while num >= 1024 do num = num / 1024 i += 1 end "#{format('%.2f', num)} #{label[i]}" end end
Version data entries
5 entries across 5 versions & 1 rubygems