Top level install helper method. Allows you to install gems interactively:
% irb >> Gem.install "minitest" Fetching: minitest-5.14.0.gem (100%) => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]
Get the default RubyGems API host. This is normally https://rubygems.org
.
Set
the default RubyGems API host.
Set
array of platforms this RubyGems supports (primarily for testing).
Array
of platforms this RubyGems supports.
The directory prefix this RubyGems was installed at. If your prefix is in a standard location (ie, rubygems is installed where you’d expect it to be), then prefix returns nil.
Returns the singleton instance.
Returns a topologically sorted array of nodes. The array is sorted from children to parents, i.e. the first element has no child and the last node has no parent.
If there is a cycle, TSort::Cyclic
is raised.
class G include TSort def initialize(g) @g = g end def tsort_each_child(n, &b) @g[n].each(&b) end def tsort_each_node(&b) @g.each_key(&b) end end graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) p graph.tsort #=> [4, 2, 3, 1] graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) p graph.tsort # raises TSort::Cyclic
Returns a topologically sorted array of nodes. The array is sorted from children to parents, i.e. the first element has no child and the last node has no parent.
The graph is represented by each_node and each_child. each_node should have call
method which yields for each node in the graph. each_child should have call
method which takes a node argument and yields for each child node.
If there is a cycle, TSort::Cyclic
is raised.
g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} each_node = lambda {|&b| g.each_key(&b) } each_child = lambda {|n, &b| g[n].each(&b) } p TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1] g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_node = lambda {|&b| g.each_key(&b) } each_child = lambda {|n, &b| g[n].each(&b) } p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
Returns a 2-element array containing the normalized signed float fraction
and integer exponent
of x
such that:
x = fraction * 2**exponent
See IEEE 754 double-precision binary floating-point format: binary64.
Domain: [-INFINITY, INFINITY]
.
Range
[-INFINITY, INFINITY]
.
Examples:
frexp(-INFINITY) # => [-Infinity, -1] frexp(-2.0) # => [-0.5, 2] frexp(-1.0) # => [-0.5, 1] frexp(0.0) # => [0.0, 0] frexp(1.0) # => [0.5, 1] frexp(2.0) # => [0.5, 2] frexp(INFINITY) # => [Infinity, -1]
Related: Math.ldexp
(inverse of Math.frexp
).
Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the fork
call returns twice, once in the parent, returning the process ID of the child, and once in the child, returning nil. The child process can exit using Kernel.exit!
to avoid running any at_exit
functions. The parent process should use Process.wait
to collect the termination statuses of its children or use Process.detach
to register disinterest in their status; otherwise, the operating system may accumulate zombie processes.
The thread calling fork is the only thread in the created child process. fork doesn’t copy other threads.
If fork is not usable, Process.respond_to?(:fork) returns false.
Note that fork(2) is not available on some platforms like Windows and NetBSD 4. Therefore you should use spawn() instead of fork().
Terminate execution immediately, effectively by calling Kernel.exit(false)
. If msg is given, it is written to STDERR prior to terminating.
An internal API for fork. Do not call this method directly. Currently, this is called via Kernel#fork
, Process.fork
, and IO.popen
with "-"
.
This method is not for casual code but for application monitoring libraries. You can add custom code before and after fork events by overriding this method.
Note: Process.daemon
may be implemented using fork(2) BUT does not go through this method. Thus, depending on your reason to hook into this method, you may also want to hook into that one. See this issue for a more detailed discussion of this.
Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP
, Process::PRIO_USER
, or Process::PRIO_PROCESS
. integer is an id indicating the particular process, process group, or user (an id of 0 means current). Lower priorities are more favorable for scheduling. Not available on all platforms.
Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
See Process.getpriority
.
Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0 Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0 Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array
of the GIDs of all the groups in the supplementary group access list. Not available on all platforms.
Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11]
Get an Array
of the group IDs in the supplemental group access list for this process.
Process.groups #=> [27, 6, 10, 11]
Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system:
the result is sorted
the result includes effective GIDs
the result does not include duplicated GIDs
the result size does not exceed the value of Process.maxgroups
You can make sure to get a sorted unique GID
list of the current process by this expression:
Process.groups.uniq.sort
Set
the supplemental group access list to the given Array
of group IDs.
Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11] Process.groups #=> [27, 6, 10, 11]
Returns the maximum number of GIDs allowed in the supplemental group access list.
Process.maxgroups #=> 32
Sets the maximum number of GIDs allowed in the supplemental group access list.
Returns a list of signal names mapped to the corresponding underlying signal numbers.
Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
Returns the generator of the group.
See the OpenSSL
documentation for EC_GROUP_get0_generator()
Returns the cofactor of the group.
See the OpenSSL
documentation for EC_GROUP_get_cofactor()