Updates the primary formatter used to format the suggestions.
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
.
Returns a new URI object constructed from the given string uri
:
URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top> URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
It’s recommended to first ::escape string uri
if it may contain invalid URI
characters.
Mirror the Prism.parse
API by using the serialization API.
Perform an operation in a block, raising an error if it takes longer than sec
seconds to complete.
sec
Number of seconds to wait for the block to terminate. Any number may be used, including Floats to specify fractional seconds. A value of 0 or nil
will execute the block without any timeout.
klass
Exception
Class
to raise if the block fails to terminate in sec
seconds. Omitting will use the default, Timeout::Error
message
Error
message to raise with Exception
Class
. Omitting will use the default, “execution expired”
Returns the result of the block if the block completed before sec
seconds, otherwise throws an exception, based on the value of klass
.
The exception thrown to terminate the given block cannot be rescued inside the block unless klass
is given explicitly. However, the block can use ensure to prevent the handling of the exception. For that reason, this method cannot be relied on to enforce timeouts for untrusted blocks.
If a scheduler is defined, it will be used to handle the timeout by invoking Scheduler#timeout_after.
Note that this is both a method of module Timeout
, so you can include Timeout
into your classes so they have a timeout
method, as well as a module method, so you can call it directly as Timeout.timeout()
.
Perform an operation in a block, raising an error if it takes longer than sec
seconds to complete.
sec
Number of seconds to wait for the block to terminate. Any number may be used, including Floats to specify fractional seconds. A value of 0 or nil
will execute the block without any timeout.
klass
Exception
Class
to raise if the block fails to terminate in sec
seconds. Omitting will use the default, Timeout::Error
message
Error
message to raise with Exception
Class
. Omitting will use the default, “execution expired”
Returns the result of the block if the block completed before sec
seconds, otherwise throws an exception, based on the value of klass
.
The exception thrown to terminate the given block cannot be rescued inside the block unless klass
is given explicitly. However, the block can use ensure to prevent the handling of the exception. For that reason, this method cannot be relied on to enforce timeouts for untrusted blocks.
If a scheduler is defined, it will be used to handle the timeout by invoking Scheduler#timeout_after.
Note that this is both a method of module Timeout
, so you can include Timeout
into your classes so they have a timeout
method, as well as a module method, so you can call it directly as Timeout.timeout()
.
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
.
Returns a 2-element array equivalent to:
[Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
See logarithmic gamma function.
Domain: (-INFINITY, INFINITY]
.
Range
of first element: (-INFINITY, INFINITY]
.
Second element is -1 or 1.
Examples:
lgamma(-4.0) # => [Infinity, -1] lgamma(-3.0) # => [Infinity, -1] lgamma(-2.0) # => [Infinity, -1] lgamma(-1.0) # => [Infinity, -1] lgamma(0.0) # => [Infinity, 1] lgamma(1.0) # => [0.0, 1] lgamma(2.0) # => [0.0, 1] lgamma(3.0) # => [0.6931471805599436, 1] lgamma(4.0) # => [1.7917594692280545, 1] lgamma(-2.5) # => [-0.05624371649767279, -1] lgamma(-1.5) # => [0.8600470153764797, 1] lgamma(-0.5) # => [1.265512123484647, -1] lgamma(0.5) # => [0.5723649429247004, 1] lgamma(1.5) # => [-0.12078223763524676, 1] lgamma(2.5) # => [0.2846828704729205, 1]
Related: Math.gamma
.
Creates a new child process by doing one of the following in that process:
Passing string command_line
to the shell.
Invoking the executable at exe_path
.
This method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Returns the process ID (pid) of the new process, without waiting for it to complete.
To avoid zombie processes, the parent process should call either:
Process.wait
, to collect the termination statuses of its children.
Process.detach
, to register disinterest in their status.
The new process is created using the exec system call; it may inherit some of its environment from the calling program (possibly including open file descriptors).
Argument env
, if given, is a hash that affects ENV
for the new process; see Execution Environment.
Argument options
is a hash of options for the new process; see Execution Options.
The first required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more meta characters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. Process.wait # => 798847 spawn('exit') # => 798848 # Built-in. Process.wait # => 798848 spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. Process.wait # => 798849 spawn('date > /nop/date.tmp') # => 798882 # Issues error message. Process.wait # => 798882
The command line may also contain arguments and options for the command:
spawn('echo "Foo"') # => 799031 Process.wait # => 799031
Output:
Foo
See Execution Shell for details about the shell.
Raises an exception if the new process could not execute.
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable to be called, and the string to be used as the name of the executing process.
spawn('/usr/bin/date') # Path to date on Unix-style system. Process.wait
Output:
Mon Aug 28 11:43:10 AM CDT 2023
Ruby invokes the executable directly. This form does not use the shell; see Arguments args for caveats.
If one or more args
is given, each is an argument or option to be passed to the executable:
spawn('echo', 'C*') # => 799392 Process.wait # => 799392 spawn('echo', 'hello', 'world') # => 799393 Process.wait # => 799393
Output:
C* hello world
Raises an exception if the new process could not execute.
Returns a Process::Tms
structure that contains user and system CPU times for the current process, and for its children processes:
Process.times # => #<struct Process::Tms utime=55.122118, stime=35.533068, cutime=0.0, cstime=0.002846>
The precision is platform-defined.
def foo((bar, baz)); end
^^^^^^^^^^
def foo(bar: baz); end
^^^^^^^^
def foo(bar: baz); end
^^^^^^^^