Ruby/Справочник/FileTest
Класс FileTest
править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).
Методы объекта
blockdev?, chardev?, directory?, executable?, executable_real?, exist?, exists?, file?, grpowned?, identical?, owned?, pipe?, readable?, readable_real?, setgid?, setuid?, size?, size, socket?, sticky?, symlink?, writable?, writable_real?, zero?
FileTest#blockdev?
правитьFile.blockdev?(file_name) => true or false
Returns true if the named file is a block device.
FileTest#chardev?
правитьFile.chardev?(file_name) => true or false
Returns true if the named file is a character device.
FileTest#directory?
правитьFile.directory?(file_name) => true or false
Returns true if the named file is a directory, false otherwise.
File.directory?(".")
FileTest#executable?
правитьFile.executable?(file_name) => true or false
Returns true if the named file is executable by the effective user id of this process.
FileTest#executable_real?
правитьFile.executable_real?(file_name) => true or false
Returns true if the named file is executable by the real user id of this process.
FileTest#exist?
правитьFile.exist?(file_name) => true or false File.exists?(file_name) => true or false (obsolete)
Return true if the named file exists.
FileTest#exists?
правитьFile.exist?(file_name) => true or false File.exists?(file_name) => true or false (obsolete)
Return true if the named file exists.
FileTest#file?
правитьFile.file?(file_name) => true or false
Returns true if the named file exists and is a regular file.
FileTest#grpowned?
править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.
FileTest#identical?
править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
FileTest#owned?
править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.
FileTest#pipe?
правитьFile.pipe?(file_name) => true or false
Returns true if the named file is a pipe.
FileTest#readable?
правитьFile.readable?(file_name) => true or false
Returns true if the named file is readable by the effective user id of this process.
FileTest#readable_real?
правитьFile.readable_real?(file_name) => true or false
Returns true if the named file is readable by the real user id of this process.
FileTest#setgid?
правитьFile.setgid?(file_name) => true or false
Returns true if the named file has the setgid bit set.
FileTest#setuid?
правитьFile.setuid?(file_name) => true or false
Returns true if the named file has the setuid bit set.
FileTest#size
правитьFile.size(file_name) => integer
Returns the size of file_name.
FileTest#size?
правитьFile.file?(file_name) => integer or nil
Returns nil if file_name doesn't exist or has zero size, the size of the file otherwise.
FileTest#socket?
правитьFile.socket?(file_name) => true or false
Returns true if the named file is a socket.
FileTest#sticky?
правитьFile.sticky?(file_name) => true or false
Returns true if the named file has the sticky bit set.
FileTest#symlink?
правитьFile.symlink?(file_name) => true or false
Returns true if the named file is a symbolic link.
FileTest#writable?
правитьFile.writable?(file_name) => true or false
Returns true if the named file is writable by the effective user id of this process.
FileTest#writable_real?
правитьFile.writable_real?(file_name) => true or false
Returns true if the named file is writable by the real user id of this process.
FileTest#zero?
правитьFile.zero?(file_name) => true or false
Returns true if the named file exists and has a zero size.