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

Version Path
ayadn-2.1 lib/ayadn/extend.rb
ayadn-2.0.12 lib/ayadn/extend.rb
ayadn-2.0.11 lib/ayadn/extend.rb
ayadn-2.0.10 lib/ayadn/extend.rb
ayadn-2.0.9 lib/ayadn/extend.rb
ayadn-2.0.8 lib/ayadn/extend.rb
ayadn-2.0.7 lib/ayadn/extend.rb
ayadn-2.0.6 lib/ayadn/extend.rb
ayadn-2.0.5 lib/ayadn/extend.rb
ayadn-2.0.4 lib/ayadn/extend.rb
ayadn-2.0.3 lib/ayadn/extend.rb
ayadn-2.0.2 lib/ayadn/extend.rb
ayadn-2.0.1 lib/ayadn/extend.rb
ayadn-2.0 lib/ayadn/extend.rb