Sha256: 005ebc8a14e96a9ad16b013d5058ea18f08cb6d01c859add5a684b9a32309a9e
Contents?: true
Size: 528 Bytes
Versions: 14
Compression:
Stored size: 528 Bytes
Contents
# encoding: utf-8 class String def is_integer? begin temp = self.to_i.to_s return false if temp == "0" Integer(temp) return true rescue ArgumentError return false end end end class Integer def to_filesize { 'B' => 1024, 'KB' => 1024 * 1024, 'MB' => 1024 * 1024 * 1024, 'GB' => 1024 * 1024 * 1024 * 1024, 'TB' => 1024 * 1024 * 1024 * 1024 * 1024 }.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)} #{e}" if self < s } end end
Version data entries
14 entries across 14 versions & 1 rubygems