Returns the IPv6 zone identifier, if present. Raises InvalidAddressError
if not an IPv6 address.
Sets the date-time format.
Argument datetime_format
should be either of these:
A string suitable for use as a format for method Time#strftime
.
nil
: the logger uses '%Y-%m-%dT%H:%M:%S.%6N'
.
Returns the date-time format; see datetime_format=
.
Creates an option from the given parameters params
. See Parameters for New Options.
The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See Option Handlers.
The new option is added at the head of the summary.
Creates an option from the given parameters params
. See Parameters for New Options.
The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See Option Handlers.
The new option is added at the tail of the summary.
Closes the incoming port and returns whether it was already closed. All further attempts to Ractor.receive
in the ractor, and send
to the ractor will fail with Ractor::ClosedError
.
r = Ractor.new {sleep(500)} r.close_incoming #=> false r.close_incoming #=> true r.send('test') # Ractor::ClosedError (The incoming-port is already closed)
Removes tracing for the specified command on the given global variable and returns nil
. If no command is specified, removes all tracing for that variable and returns an array containing the commands actually removed.
Returns a pretty printed object as a string.
See the PP
module for more information.
Ruby tries to load the library named string relative to the directory containing the requiring file. If the file does not exist a LoadError is raised. Returns true
if the file was loaded and false
if the file was already loaded before.
Calls the block with each successive overlapped n
-tuple of elements; returns self
:
a = [] (1..5).each_cons(3) {|element| a.push(element) } a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] a = [] h = {foo: 0, bar: 1, baz: 2, bam: 3} h.each_cons(2) {|element| a.push(element) } a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]]
With no block given, returns an Enumerator
.
Creates a new MonitorMixin::ConditionVariable
associated with the Monitor
object.
Counts symbols for each Symbol
type.
This method is only for MRI developers interested in performance and memory usage of Ruby programs.
If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect.
Note: The contents of the returned hash is implementation defined. It may be changed in future.
This method is only expected to work with C Ruby.
On this version of MRI, they have 3 types of Symbols (and 1 total counts).
* mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol)
Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnum
s, Symbol
s true
, false
, and nil
) are never returned. In the example below, each_object returns both the numbers we defined and several constants defined in the Math
module.
If no block is given, an enumerator is returned instead.
a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}"
produces:
12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7
Removes all finalizers for obj.
Load yaml
in to a Ruby data structure. If multiple documents are provided, the object contained in the first document will be returned. filename
will be used in the exception message if any exception is raised while parsing. If yaml
is empty, it returns the specified fallback
return value, which defaults to false
.
Raises a Psych::SyntaxError
when a YAML
syntax error is detected.
Example:
Psych.unsafe_load("--- a") # => 'a' Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b'] begin Psych.unsafe_load("--- `", filename: "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(file.txt): found character that cannot start any token" end
When the optional symbolize_names
keyword argument is set to a true value, returns symbols for keys in Hash
objects (default: strings).
Psych.unsafe_load("---\n foo: bar") # => {"foo"=>"bar"} Psych.unsafe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
Raises a TypeError
when ‘yaml` parameter is NilClass
NOTE: This method *should not* be used to parse untrusted documents, such as YAML
documents that are supplied via user input. Instead, please use the load method or the safe_load
method.
Dump Ruby object
to a JSON
string.
Returns whether or not automatic compaction has been enabled.
Updates automatic compaction mode.
When enabled, the compactor will execute on every major collection.
Enabling compaction will degrade performance on major collections.
Return measured GC total time in nano seconds.
Adds a post-installs hook that will be passed a Gem::DependencyInstaller
and a list of installed specifications when Gem::DependencyInstaller#install
is complete
Adds a post-uninstall hook that will be passed a Gem::Uninstaller
instance and the spec that was uninstalled when Gem::Uninstaller#uninstall
is called