O'Reilly logo

Ruby in a Nutshell by Yukihiro Matsumoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required