Sha256: 8b2b44e49118a34740ba11f9838868131c62283158bf8687a1b380ae791a0fc6

Contents?: true

Size: 492 Bytes

Versions: 5

Compression:

Stored size: 492 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8
class String
    def is_integer?
      self.to_i.to_s == self
    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
class Numeric
  def percent_of(n)
    self.to_f / n.to_f * 100.0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ayadn-0.6.4 lib/ayadn/extend.rb
ayadn-0.6.3 lib/ayadn/extend.rb
ayadn-0.6.2 lib/ayadn/extend.rb
ayadn-0.6.1 lib/ayadn/extend.rb
ayadn-0.6.0 lib/ayadn/extend.rb