Name

File — File class

Synopsis

A File represents an stdio object that connected to a regular file. open returns an instance of this class for regular files.

Inherited Class

IO

Class Methods

File::atime(path)

Returns the last access time for path.

File::basename(path[, suffix])

Returns the filename at the end of path. If suffix is specified, it’s deleted from the end of the filename.

File.basename("/home/matz/bin/ruby.exe")         #=> "ruby.exe"
File.basename("/home/matz/bin/ruby.exe", ".exe") #=> "ruby"
File::blockdev?(path)

Returns true if path is a block device.

File::chardev?(path)

Returns true if path is a character device.

File::chmod(mode, path...)

Changes the permission mode of the specified files.

File::chown(owner, group, path...)

Changes the owner and group of the specified files.

File::ctime(path)

Returns the last inode change time for path.

File::delete(path...)
File::unlink(path...)

Deletes the specified files.

File::directory?(path)

Returns true if path is a directory.

File::dirname(path)

Returns the directory portion of path, without the final filename.

File::executable?(path)

Returns true if path is executable.

File::executable_real?(path)

Returns true if path is executable with real user permissions.

File::exist?(path)

Returns true if path exists.

File::expand_path(path[, dir])

Returns the absolute path of path, expanding ~ to the process owner’s home directory, and ~user to the user’s home directory. Relative paths are resolved from the directory specified by dir, or the current working directory ...

Get Ruby in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.