class File
ByteSize adds three new methods to the File class:
-
::bytesize
-
::bytesize?
-
#bytesize
Plus the equivalent methods for IECByteSize:
-
::iecbytesize
-
::iecbytesize?
-
#iecbytesize
Public Class Methods
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
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
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
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
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
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