Sha256: 8865b3f66717cf23f5d8ebebe649df27bce5742779a169be213f38dba732efbb

Contents?: true

Size: 306 Bytes

Versions: 20

Compression:

Stored size: 306 Bytes

Contents

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

20 entries across 20 versions & 1 rubygems

Version Path
tailog-0.7.0 lib/tailog/ext/integer.rb
tailog-0.6.9 lib/tailog/ext/integer.rb
tailog-0.6.8 lib/tailog/ext/integer.rb
tailog-0.6.7 lib/tailog/ext/integer.rb
tailog-0.6.6 lib/tailog/ext/integer.rb
tailog-0.6.5 lib/tailog/ext/integer.rb
tailog-0.6.4 lib/tailog/ext/integer.rb
tailog-0.6.3 lib/tailog/ext/integer.rb
tailog-0.6.2 lib/tailog/ext/integer.rb
tailog-0.6.1 lib/tailog/ext/integer.rb
tailog-0.6.0 lib/tailog/ext/integer.rb
tailog-0.5.9 lib/tailog/ext/integer.rb
tailog-0.5.8 lib/tailog/ext/integer.rb
tailog-0.5.7 lib/tailog/ext/integer.rb
tailog-0.5.6 lib/tailog/ext/integer.rb
tailog-0.5.5 lib/tailog/ext/integer.rb
tailog-0.5.4 lib/tailog/ext/integer.rb
tailog-0.5.2 lib/tailog/ext/integer.rb
tailog-0.5.1 lib/tailog/ext/integer.rb
tailog-0.5.0 lib/tailog/ext/integer.rb