Returns true
if the file at path new
is newer than all the files at paths in array old_list
; false
otherwise.
Argument new
and the elements of old_list
should be interpretable as paths:
FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false
A non-existent file is considered to be infinitely old.
Related: FileUtils.touch
.
Returns true
if the file at path new
is newer than all the files at paths in array old_list
; false
otherwise.
Argument new
and the elements of old_list
should be interpretable as paths:
FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false
A non-existent file is considered to be infinitely old.
Related: FileUtils.touch
.
Changes permissions on the entries at the paths given in list
(a single path or an array of paths) to the permissions given by mode
; returns list
if it is an array, [list]
otherwise:
Modifies each entry that is a regular file using File.chmod
.
Modifies each entry that is a symbolic link using File.lchmod
.
Argument list
or its elements should be interpretable as paths.
Argument mode
may be either an integer or a string:
Integer mode
: represents the permission bits to be set:
FileUtils.chmod(0755, 'src0.txt') FileUtils.chmod(0644, ['src0.txt', 'src0.dat'])
String mode
: represents the permissions to be set:
The string is of the form [targets][[operator][perms[,perms]]
, where:
targets
may be any combination of these letters:
'u'
: permissions apply to the file’s owner.
'g'
: permissions apply to users in the file’s group.
'o'
: permissions apply to other users not in the file’s group.
'a'
(the default): permissions apply to all users.
operator
may be one of these letters:
'+'
: adds permissions.
'-'
: removes permissions.
'='
: sets (replaces) permissions.
perms
(may be repeated, with separating commas) may be any combination of these letters:
'r'
: Read.
'w'
: Write.
'x'
: Execute (search, for a directory).
'X'
: Search (for a directories only; must be used with '+'
)
's'
: Uid or gid.
't'
: Sticky bit.
Examples:
FileUtils.chmod('u=wrx,go=rx', 'src1.txt') FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby')
Keyword arguments:
noop: true
- does not change permissions; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true) FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true) FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true)
Output:
chmod 755 src0.txt chmod 644 src0.txt src0.dat chmod u=wrx,go=rx src1.txt chmod u=wrx,go=rx /usr/bin/ruby
Related: FileUtils.chmod_R
.
Changes permissions on the entries at the paths given in list
(a single path or an array of paths) to the permissions given by mode
; returns list
if it is an array, [list]
otherwise:
Modifies each entry that is a regular file using File.chmod
.
Modifies each entry that is a symbolic link using File.lchmod
.
Argument list
or its elements should be interpretable as paths.
Argument mode
may be either an integer or a string:
Integer mode
: represents the permission bits to be set:
FileUtils.chmod(0755, 'src0.txt') FileUtils.chmod(0644, ['src0.txt', 'src0.dat'])
String mode
: represents the permissions to be set:
The string is of the form [targets][[operator][perms[,perms]]
, where:
targets
may be any combination of these letters:
'u'
: permissions apply to the file’s owner.
'g'
: permissions apply to users in the file’s group.
'o'
: permissions apply to other users not in the file’s group.
'a'
(the default): permissions apply to all users.
operator
may be one of these letters:
'+'
: adds permissions.
'-'
: removes permissions.
'='
: sets (replaces) permissions.
perms
(may be repeated, with separating commas) may be any combination of these letters:
'r'
: Read.
'w'
: Write.
'x'
: Execute (search, for a directory).
'X'
: Search (for a directories only; must be used with '+'
)
's'
: Uid or gid.
't'
: Sticky bit.
Examples:
FileUtils.chmod('u=wrx,go=rx', 'src1.txt') FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby')
Keyword arguments:
noop: true
- does not change permissions; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true) FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true) FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true)
Output:
chmod 755 src0.txt chmod 644 src0.txt src0.dat chmod u=wrx,go=rx src1.txt chmod u=wrx,go=rx /usr/bin/ruby
Related: FileUtils.chmod_R
.
Like FileUtils.chmod
, but changes permissions recursively.
Like FileUtils.chmod
, but changes permissions recursively.
Changes the owner and group on the entries at the paths given in list
(a single path or an array of paths) to the given user
and group
; returns list
if it is an array, [list]
otherwise:
Modifies each entry that is a regular file using File.chown
.
Modifies each entry that is a symbolic link using File.lchown
.
Argument list
or its elements should be interpretable as paths.
User and group:
Argument user
may be a user name or a user id; if nil
or -1
, the user is not changed.
Argument group
may be a group name or a group id; if nil
or -1
, the group is not changed.
The user must be a member of the group.
Examples:
# One path. # User and group as string names. File.stat('src0.txt').uid # => 1004 File.stat('src0.txt').gid # => 1004 FileUtils.chown('user2', 'group1', 'src0.txt') File.stat('src0.txt').uid # => 1006 File.stat('src0.txt').gid # => 1005 # User and group as uid and gid. FileUtils.chown(1004, 1004, 'src0.txt') File.stat('src0.txt').uid # => 1004 File.stat('src0.txt').gid # => 1004 # Array of paths. FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat']) # Directory (not recursive). FileUtils.chown('user2', 'group1', '.')
Keyword arguments:
noop: true
- does not change permissions; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true) FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true) FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.chown('user2', 'group1', path, noop: true, verbose: true) FileUtils.chown('user2', 'group1', '.', noop: true, verbose: true)
Output:
chown user2:group1 src0.txt chown 1004:1004 src0.txt chown 1006:1005 src0.txt src0.dat chown user2:group1 src0.txt chown user2:group1 .
Related: FileUtils.chown_R
.
Changes the owner and group on the entries at the paths given in list
(a single path or an array of paths) to the given user
and group
; returns list
if it is an array, [list]
otherwise:
Modifies each entry that is a regular file using File.chown
.
Modifies each entry that is a symbolic link using File.lchown
.
Argument list
or its elements should be interpretable as paths.
User and group:
Argument user
may be a user name or a user id; if nil
or -1
, the user is not changed.
Argument group
may be a group name or a group id; if nil
or -1
, the group is not changed.
The user must be a member of the group.
Examples:
# One path. # User and group as string names. File.stat('src0.txt').uid # => 1004 File.stat('src0.txt').gid # => 1004 FileUtils.chown('user2', 'group1', 'src0.txt') File.stat('src0.txt').uid # => 1006 File.stat('src0.txt').gid # => 1005 # User and group as uid and gid. FileUtils.chown(1004, 1004, 'src0.txt') File.stat('src0.txt').uid # => 1004 File.stat('src0.txt').gid # => 1004 # Array of paths. FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat']) # Directory (not recursive). FileUtils.chown('user2', 'group1', '.')
Keyword arguments:
noop: true
- does not change permissions; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true) FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true) FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.chown('user2', 'group1', path, noop: true, verbose: true) FileUtils.chown('user2', 'group1', '.', noop: true, verbose: true)
Output:
chown user2:group1 src0.txt chown 1004:1004 src0.txt chown 1006:1005 src0.txt src0.dat chown user2:group1 src0.txt chown user2:group1 .
Related: FileUtils.chown_R
.
Like FileUtils.chown
, but changes owner and group recursively.
Like FileUtils.chown
, but changes owner and group recursively.
Updates modification times (mtime) and access times (atime) of the entries given by the paths in list
(a single path or an array of paths); returns list
if it is an array, [list]
otherwise.
By default, creates an empty file for any path to a non-existent entry; use keyword argument nocreate
to raise an exception instead.
Argument list
or its elements should be interpretable as paths.
Examples:
# Single path. f = File.new('src0.txt') # Existing file. f.atime # => 2022-06-10 11:11:21.200277 -0700 f.mtime # => 2022-06-10 11:11:21.200277 -0700 FileUtils.touch('src0.txt') f = File.new('src0.txt') f.atime # => 2022-06-11 08:28:09.8185343 -0700 f.mtime # => 2022-06-11 08:28:09.8185343 -0700 # Array of paths. FileUtils.touch(['src0.txt', 'src0.dat'])
Keyword arguments:
mtime: time
- sets the entry’s mtime to the given time, instead of the current time.
nocreate: true
- raises an exception if the entry does not exist.
noop: true
- does not touch entries; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.touch('src0.txt', noop: true, verbose: true) FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.touch(path, noop: true, verbose: true)
Output:
touch src0.txt touch src0.txt src0.dat touch src0.txt
Related: FileUtils.uptodate?
.
Updates modification times (mtime) and access times (atime) of the entries given by the paths in list
(a single path or an array of paths); returns list
if it is an array, [list]
otherwise.
By default, creates an empty file for any path to a non-existent entry; use keyword argument nocreate
to raise an exception instead.
Argument list
or its elements should be interpretable as paths.
Examples:
# Single path. f = File.new('src0.txt') # Existing file. f.atime # => 2022-06-10 11:11:21.200277 -0700 f.mtime # => 2022-06-10 11:11:21.200277 -0700 FileUtils.touch('src0.txt') f = File.new('src0.txt') f.atime # => 2022-06-11 08:28:09.8185343 -0700 f.mtime # => 2022-06-11 08:28:09.8185343 -0700 # Array of paths. FileUtils.touch(['src0.txt', 'src0.dat'])
Keyword arguments:
mtime: time
- sets the entry’s mtime to the given time, instead of the current time.
nocreate: true
- raises an exception if the entry does not exist.
noop: true
- does not touch entries; returns nil
.
verbose: true
- prints an equivalent command:
FileUtils.touch('src0.txt', noop: true, verbose: true) FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true) FileUtils.touch(path, noop: true, verbose: true)
Output:
touch src0.txt touch src0.txt src0.dat touch src0.txt
Related: FileUtils.uptodate?
.
Returns an array of the string names of FileUtils methods that accept one or more keyword arguments:
FileUtils.commands.sort.take(3) # => ["cd", "chdir", "chmod"]
Returns the arc tangent of y
and x
in radians.
Domain of y
: [-INFINITY, INFINITY]
.
Domain of x
: [-INFINITY, INFINITY]
.
Range: [-PI, PI]
.
Examples:
atan2(-1.0, -1.0) # => -2.356194490192345 # -3*PI/4 atan2(-1.0, 0.0) # => -1.5707963267948966 # -PI/2 atan2(-1.0, 1.0) # => -0.7853981633974483 # -PI/4 atan2(0.0, -1.0) # => 3.141592653589793 # PI
Returns the arc tangent of x
.
Domain: [-INFINITY, INFINITY]
.
Range: [-PI/2, PI/2]
.
Examples:
atan(-INFINITY) # => -1.5707963267948966 # -PI2 atan(-PI) # => -1.2626272556789115 atan(-PI/2) # => -1.0038848218538872 atan(0.0) # => 0.0 atan(PI/2) # => 1.0038848218538872 atan(PI) # => 1.2626272556789115 atan(INFINITY) # => 1.5707963267948966 # PI/2
Returns the inverse hyperbolic tangent of x
.
Domain: [-1, 1]
.
Range: [-INFINITY, INFINITY]
.
Examples:
atanh(-1.0) # => -Infinity atanh(0.0) # => 0.0 atanh(1.0) # => Infinity
Returns the value of the gamma function for x
.
Domain: (-INFINITY, INFINITY]
excluding negative integers.
Range: [-INFINITY, INFINITY]
.
Examples:
gamma(-2.5) # => -0.9453087204829431 gamma(-1.5) # => 2.3632718012073513 gamma(-0.5) # => -3.5449077018110375 gamma(0.0) # => Infinity gamma(1.0) # => 1.0 gamma(2.0) # => 1.0 gamma(3.0) # => 2.0 gamma(4.0) # => 6.0 gamma(5.0) # => 24.0
Related: Math.lgamma
.