class File

ByteSize adds three new methods to the File class:

Plus the equivalent methods for IECByteSize:

Public Class Methods

bytesize( file_name ) → bytesize click to toggle source

Identical to {File.size}[http://ruby-doc.org/core/File.html#method-c-size] except that the value is returned as an instance of ByteSize.

# File lib/bytesize.rb, line 1140
def self.bytesize( file_name )
        ByteSize.new( self.size(file_name) )
end
bytesize?( file_name ) → bytesize or nil click to toggle source

Identical to {File.size?}[http://ruby-doc.org/core/File.html#method-c-size-3F] except that the value is returned as an instance of ByteSize.

# File lib/bytesize.rb, line 1153
def self.bytesize?( file_name )
        sz = self.size?(file_name)
        sz.nil? ? nil : ByteSize.new(sz)
end
iecbytesize( file_name ) → bytesize click to toggle source

Identical to {File.size}[http://ruby-doc.org/core/File.html#method-c-size] except that the value is returned as an instance of IECByteSize.

# File lib/bytesize.rb, line 1180
def self.iecbytesize( file_name )
        IECByteSize.new( self.size(file_name) )
end
iecbytesize?( file_name ) → bytesize or nil click to toggle source

Identical to {File.size?}[http://ruby-doc.org/core/File.html#method-c-size-3F] except that the value is returned as an instance of IECByteSize.

# File lib/bytesize.rb, line 1193
def self.iecbytesize?( file_name )
        sz = self.size?(file_name)
        sz.nil? ? nil : IECByteSize.new(sz)
end

Public Instance Methods

bytesize → bytesize click to toggle source

Identical to {File#size}[http://ruby-doc.org/core/File.html#method-i-size] except that the value is returned as an instance of ByteSize.

# File lib/bytesize.rb, line 1167
def bytesize
        ByteSize.new(size)
end
iecbytesize → bytesize click to toggle source

Identical to {File#size}[http://ruby-doc.org/core/File.html#method-i-size] except that the value is returned as an instance of IECByteSize.

# File lib/bytesize.rb, line 1207
def iecbytesize
        IECByteSize.new(size)
end