Results for: "module_function"

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.

No documentation available

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 (Fixnums, Symbols 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.

Return measured GC total time in nano seconds.

The RbConfig object for the deployment target platform.

This is usually the same as the running platform, but may be different if you are cross-compiling.

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

Adds a pre-uninstall hook that will be passed an Gem::Uninstaller instance and the spec that will be uninstalled when Gem::Uninstaller#uninstall is called

The path to standard location of the user’s configuration directory.

Adds DidYouMean functionality to an error using a given spell checker

No documentation available
No documentation available

Returns the language-dependent source file name for configuration checks.

Tests for the presence of a --with-config or --without-config option. Returns true if the with option is given, false if the without option is given, and the default value otherwise.

This can be useful for adding custom definitions, such as debug information.

Example:

if with_config("debug")
   $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
end

Sets a target name that the user can then use to configure various “with” options with on the command line by using that name. For example, if the target is set to “foo”, then the user could use the --with-foo-dir=prefix, --with-foo-include=dir and --with-foo-lib=dir command line options to tell where to search for header/library files.

You may pass along additional parameters to specify default values. If one is given it is taken as default prefix, and if two are given they are taken as “include” and “lib” defaults in that order.

In any case, the return value will be an array of determined “include” and “lib” directories, either of which can be nil if no corresponding command line option is given when no default value is specified.

Note that dir_config only adds to the list of places to search for libraries and include files. It does not link the libraries into your application.

Returns compile/link information about an installed library in a tuple of [cflags, ldflags, libs], by using the command found first in the following commands:

  1. If --with-{pkg}-config={command} is given via command line option: {command} {options}

  2. {pkg}-config {options}

  3. pkg-config {options} {pkg}

Where options is the option name without dashes, for instance "cflags" for the --cflags flag.

The values obtained are appended to $INCFLAGS, $CFLAGS, $LDFLAGS and $libs.

If one or more options argument is given, the config command is invoked with the options and a stripped output string is returned without modifying any of the global values mentioned above.

No documentation available

Returns a clock time as determined by POSIX function clock_gettime():

Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID) # => 198.650379677

Argument clock_id should be a symbol or a constant that specifies the clock whose time is to be returned; see below.

Optional argument unit should be a symbol that specifies the unit to be used in the returned clock time; see below.

Argument clock_id

Argument clock_id specifies the clock whose time is to be returned; it may be a constant such as Process::CLOCK_REALTIME, or a symbol shorthand such as :CLOCK_REALTIME.

The supported clocks depend on the underlying operating system; this method supports the following clocks on the indicated platforms (raises Errno::EINVAL if called with an unsupported clock):

Note that SUS stands for Single Unix Specification. SUS contains POSIX and clock_gettime is defined in the POSIX part. SUS defines :CLOCK_REALTIME as mandatory but :CLOCK_MONOTONIC, :CLOCK_PROCESS_CPUTIME_ID, and :CLOCK_THREAD_CPUTIME_ID are optional.

Certain emulations are used when the given clock_id is not supported directly:

Argument unit

Optional argument unit (default :float_second) specifies the unit for the returned value.

Examples:

Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond)
# => 203605054.825
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond)
# => 203643.696848
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_second)
# => 203.762181929
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :microsecond)
# => 204123212
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :millisecond)
# => 204298
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond)
# => 204602286036
Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :second)
# => 204

The underlying function, clock_gettime(), returns a number of nanoseconds. Float object (IEEE 754 double) is not enough to represent the return value for :CLOCK_REALTIME. If the exact nanoseconds value is required, use :nanosecond as the unit.

The origin (time zero) of the returned value is system-dependent, and may be, for example, system start up time, process start up time, the Epoch, etc.

The origin in :CLOCK_REALTIME is defined as the Epoch: 1970-01-01 00:00:00 UTC; some systems count leap seconds and others don’t, so the result may vary across systems.

Search took: 6ms  ·  Total Results: 3609