Module

FileTest

Inheritance

FileTest implements file test operations similar to those used in File::Stat. It exists as a standalone module, and its methods are also insinuated into the File class. (Note that this is not done by inclusion: the interpreter cheats).

Methods

Instance

Visibility Signature
public blockdev? (p1)
public chardev? (p1)
public directory? (p1)
public executable? (p1)
public executable_real? (p1)
public exist? (p1)
public exists? (p1)
public file? (p1)
public grpowned? (p1)
public identical? (p1, p2)
public owned? (p1)
public pipe? (p1)
public readable? (p1)
public readable_real? (p1)
public setgid? (p1)
public setuid? (p1)
public size (p1)
public size? (p1)
public socket? (p1)
public sticky? (p1)
public symlink? (p1)
public writable? (p1)
public writable_real? (p1)
public zero? (p1)

Instance Method Detail

File.blockdev?(file_name) => true or false

Returns true if the named file is a block device.

File.chardev?(file_name) => true or false

Returns true if the named file is a character device.

File.directory?(file_name) => true or false

Returns true if the named file is a directory, false otherwise.

   File.directory?(".")

File.executable?(file_name) => true or false

Returns true if the named file is executable by the effective user id of this process.

File.executable_real?(file_name) => true or false

Returns true if the named file is executable by the real user id of this process.

File.exist?(file_name) => true or false
File.exists?(file_name) => true or false (obsolete)

Return true if the named file exists.

File.exist?(file_name) => true or false
File.exists?(file_name) => true or false (obsolete)

Return true if the named file exists.

File.file?(file_name) => true or false

Returns true if the named file exists and is a regular file.

File.grpowned?(file_name) => true or false

Returns true if the named file exists and the effective group id of the calling process is the owner of the file. Returns false on Windows.

File.identical?(file_1, file_2) => true or false

Returns true if the named files are identical.

    open("a", "w") {}
    p File.identical?("a", "a")      #=> true
    p File.identical?("a", "./a")    #=> true
    File.link("a", "b")
    p File.identical?("a", "b")      #=> true
    File.symlink("a", "c")
    p File.identical?("a", "c")      #=> true
    open("d", "w") {}
    p File.identical?("a", "d")      #=> false

File.owned?(file_name) => true or false

Returns true if the named file exists and the effective used id of the calling process is the owner of the file.

File.pipe?(file_name) => true or false

Returns true if the named file is a pipe.

File.readable?(file_name) => true or false

Returns true if the named file is readable by the effective user id of this process.

File.readable_real?(file_name) => true or false

Returns true if the named file is readable by the real user id of this process.

File.setgid?(file_name) => true or false

Returns true if the named file has the setgid bit set.

File.setuid?(file_name) => true or false

Returns true if the named file has the setuid bit set.

File.size(file_name) => integer

Returns the size of file_name.

File.size?(file_name) => Integer or nil

Returns nil if file_name doesn‘t exist or has zero size, the size of the file otherwise.

File.socket?(file_name) => true or false

Returns true if the named file is a socket.

File.sticky?(file_name) => true or false

Returns true if the named file has the sticky bit set.

File.symlink?(file_name) => true or false

Returns true if the named file is a symbolic link.

File.writable?(file_name) => true or false

Returns true if the named file is writable by the effective user id of this process.

File.writable_real?(file_name) => true or false

Returns true if the named file is writable by the real user id of this process.

File.zero?(file_name) => true or false

Returns true if the named file exists and has a zero size.