Constant time memory comparison. Inputs are hashed using SHA-256 to mask the length of the secret. Returns true
if the strings are identical, false
otherwise.
A Gem::Version
for the currently running RubyGems
Registers the given klass
as the class to be instantiated when parsing a URI with the given scheme
:
URI.register_scheme('MS_SEARCH', URI::Generic) # => URI::Generic URI.scheme_list['MS_SEARCH'] # => URI::Generic
Note that after calling String#upcase
on scheme
, it must be a valid constant name.
Discard changes that have not been committed and revert the last commit
Cannot revert the first commit
Quietly ensure the Gem
directory dir
contains all the proper subdirectories. If we can’t create a directory due to a permission problem, then we will silently continue.
If mode
is given, missing directories are created with this mode.
World-writable directories will never be created.
Returns true
if self
is a Monday, false
otherwise.
Returns the integer month of the year for self
, in range (1..12):
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.mon # => 1
Returns the integer month of the year for self
, in range (1..12):
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.mon # => 1
Returns true
if self
represents a Monday, false
otherwise:
t = Time.utc(2000, 1, 3) # => 2000-01-03 00:00:00 UTC t.monday? # => true
Related: Time#tuesday?
, Time#wednesday?
, Time#thursday?
.
Returns the ‘rest’ of the [stored string] (all after the current [position]), which is the [target substring]:
scanner = StringScanner.new('foobarbaz') scanner.rest # => "foobarbaz" scanner.pos = 3 scanner.rest # => "barbaz" scanner.terminate scanner.rest # => ""
Associates the given object
with the given key
; returns object
.
Searches for a hash key equivalent to the given key
; see Hash Key Equivalence.
If the key is found, replaces its value with the given object
; the ordering is not affected (see Entry Order):
h = {foo: 0, bar: 1} h[:foo] = 2 # => 2 h[:foo] # => 2
If key
is not found, creates a new entry for the given key
and object
; the new entry is last in the order (see Entry Order):
h = {foo: 0, bar: 1} h[:baz] = 2 # => 2 h[:baz] # => 2 h # => {:foo=>0, :bar=>1, :baz=>2}
Related: []
; see also Methods for Assigning.
Creates, updates, or deletes the named environment variable, returning the value. Both name
and value
may be instances of String
. See Valid Names and Values.
If the named environment variable does not exist:
If value
is nil
, does nothing.
ENV.clear ENV['foo'] = nil # => nil ENV.include?('foo') # => false ENV.store('bar', nil) # => nil ENV.include?('bar') # => false
If value
is not nil
, creates the environment variable with name
and value
:
# Create 'foo' using ENV.[]=. ENV['foo'] = '0' # => '0' ENV['foo'] # => '0' # Create 'bar' using ENV.store. ENV.store('bar', '1') # => '1' ENV['bar'] # => '1'
If the named environment variable exists:
If value
is not nil
, updates the environment variable with value value
:
# Update 'foo' using ENV.[]=. ENV['foo'] = '2' # => '2' ENV['foo'] # => '2' # Update 'bar' using ENV.store. ENV.store('bar', '3') # => '3' ENV['bar'] # => '3'
If value
is nil
, deletes the environment variable:
# Delete 'foo' using ENV.[]=. ENV['foo'] = nil # => nil ENV.include?('foo') # => false # Delete 'bar' using ENV.store. ENV.store('bar', nil) # => nil ENV.include?('bar') # => false
Raises an exception if name
or value
is invalid. See Invalid Names and Values.
Returns revision information for the erb.rb module.
The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason.
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:
true
if the command exits with status zero.
false
if the exit status is a non-zero integer.
nil
if the command could not execute.
Raises an exception (instead of returning false
or nil
) if keyword argument exception
is set to true
.
Assigns the command’s error status to $?
.
The new process is created using the system 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:
system('if true; then echo "Foo"; fi') # => true # Shell reserved word. system('exit') # => true # Built-in. system('date > /tmp/date.tmp') # => true # Contains meta character. system('date > /nop/date.tmp') # => false system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
Assigns the command’s error status to $?
:
system('exit') # => true # Built-in. $? # => #<Process::Status: pid 640610 exit 0> system('date > /nop/date.tmp') # => false $? # => #<Process::Status: pid 640742 exit 2>
The command line may also contain arguments and options for the command:
system('echo "Foo"') # => true
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 and the string to be used as the name of the executing process.
Example:
system('/usr/bin/date') # => true # Path to date on Unix-style system. system('foo') # => nil # Command failed.
Output:
Mon Aug 28 11:43:10 AM CDT 2023
Assigns the command’s error status to $?
:
system('/usr/bin/date') # => true $? # => #<Process::Status: pid 645605 exit 0> system('foo') # => nil $? # => #<Process::Status: pid 645608 exit 127>
Ruby
invokes the executable directly. This form does not use the shell; see Arguments args for caveats.
system('doesnt_exist') # => nil
If one or more args
is given, each is an argument or option to be passed to the executable:
system('echo', 'C*') # => true system('echo', 'hello', 'world') # => true
Output:
C* hello world
Raises an exception if the new process could not execute.
Returns the current status of GC stress mode.
Updates the GC stress mode.
When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations.
Enabling stress mode will degrade performance; it is only for debugging.
The flag can be true, false, or an integer bitwise-ORed with the following flags:
0x01:: no major GC 0x02:: no immediate sweep 0x04:: full mark after malloc/calloc/realloc
Executes command with expanding variables, and returns the exit status like as Kernel#system
. If werror is true and the error output is not empty, returns false
. The output will logged.
Returns an Array
of SingleResponse
for this BasicResponse
.