Sha256: 56f831b8073bdf7a074e1ac1b31d9257d735cdacce45097105a6698384f1c36b
Contents?: true
Size: 336 Bytes
Versions: 7
Compression:
Stored size: 336 Bytes
Contents
module Imgurr class Numbers class << self def to_human(number) units = %W(B KiB MiB GiB TiB) size, unit = units.reduce(number.to_f) do |(fsize, _), utype| fsize > 512 ? [fsize / 1024, utype] : (break [fsize, utype]) end return "#{"%.3f" % size} #{unit}" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems