Sha256: 3170b1062c9aad5664b2b141404f542e72243f28be1419749631a987333e41d9
Contents?: true
Size: 646 Bytes
Versions: 5
Compression:
Stored size: 646 Bytes
Contents
class Fixnum # Lifted from Rails' NumberHelper view helper def to_human_size(precision=1) size = Kernel.Float(self) case when size.to_i == 1 then "1 Byte" when size < 1024 then "#{size} Bytes" when size < 1024*1024 then "#{(size / 1024).to_display(precision)} KB" when size < 1024*1024*1024 then "#{(size / (1024*1024)).to_display(precision)} MB" when size < 1024*1024*1024*1024 then "#{(size / (1024*1024*1024)).to_display(precision)} GB" else "#{(size / (1024*1024*1024*1024)).to_display(precision)} GB" end rescue nil end def blank? false end end
Version data entries
5 entries across 5 versions & 1 rubygems