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