Waits for all children, returns an array of 2-element arrays; each subarray contains the integer pid and Process::Status
status for one of the reaped child processes:
pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 325470 pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 325495 Process.waitall # => [[325470, #<Process::Status: pid 325470 exit 13>], [325495, #<Process::Status: pid 325495 exit 14>]]
Adds a post-install hook that will be passed an Gem::Installer
instance when Gem::Installer#install
is called
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-install hook that will be passed an Gem::Installer
instance when Gem::Installer#install
is called. If the hook returns false
then the install will be aborted.
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
Installs the gem dep_or_name
and all its dependencies. Returns an Array
of installed gem specifications.
If the :prerelease
option is set and there is a prerelease for dep_or_name
the prerelease version will be installed.
Unless explicitly specified as a prerelease dependency, prerelease gems that dep_or_name
depend on will not be installed.
If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed separately.
Installs the gem and returns a loaded Gem::Specification
for the installed gem.
The gem will be installed with the following structure:
@gem_home/ cache/<gem-version>.gem #=> a cached copy of the installed gem gems/<gem-version>/... #=> extracted files specifications/<gem-version>.gemspec #=> the Gem::Specification
Installs gems for this RequestSet
using the Gem::Installer
options
.
If a block
is given an activation request
and installer
are yielded. The installer
will be nil
if a gem matching the request was already installed.
Performs the uninstall of the gem. This removes the spec, the Gem directory, and the cached .gem file.
Check if gem name
version version
is installed.
Returns whether for every element of self
, a given criterion is satisfied.
With no block and no argument, returns whether every element of self
is truthy:
[[], {}, '', 0, 0.0, Object.new].all? # => true # All truthy objects. [[], {}, '', 0, 0.0, nil].all? # => false # nil is not truthy. [[], {}, '', 0, 0.0, false].all? # => false # false is not truthy.
With argument object
given, returns whether object === ele
for every element ele
in self
:
[0, 0, 0].all?(0) # => true [0, 1, 2].all?(1) # => false ['food', 'fool', 'foot'].all?(/foo/) # => true ['food', 'drink'].all?(/foo/) # => false
With a block given, calls the block with each element in self
; returns whether the block returns only truthy values:
[0, 1, 2].all? { |ele| ele < 3 } # => true [0, 1, 2].all? { |ele| ele < 2 } # => false
With both a block and argument object
given, ignores the block and uses object
as above.
Special case: returns true
if self
is empty (regardless of any given argument or block).
Related: Enumerable#all?
Returns true
if all bits that are set (=1) in mask
are also set in self
; returns false
otherwise.
Example values:
0b1010101 self 0b1010100 mask 0b1010100 self & mask true self.allbits?(mask) 0b1010100 self 0b1010101 mask 0b1010100 self & mask false self.allbits?(mask)
Related: Integer#anybits?
, Integer#nobits?
.
Returns a string containing the characters in self
; the first character is upcased; the remaining characters are downcased:
s = 'hello World!' # => "hello World!" s.capitalize # => "Hello world!"
The casing may be affected by the given options
; see Case Mapping.
Related: String#capitalize!
.
Upcases the first character in self
; downcases the remaining characters; returns self
if any changes were made, nil
otherwise:
s = 'hello World!' # => "hello World!" s.capitalize! # => "Hello world!" s # => "Hello world!" s.capitalize! # => nil
The casing may be affected by the given options
; see Case Mapping.
Related: String#capitalize
.
Invokes the continuation. The program continues from the end of the callcc
block. If no arguments are given, the original callcc
returns nil
. If one argument is given, callcc
returns it. Otherwise, an array containing args is returned.
callcc {|cont| cont.call } #=> nil callcc {|cont| cont.call 1 } #=> 1 callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
Allocates space for a new object of class’s class and does not call initialize on the new instance. The returned object must be an instance of class.
klass = Class.new do def initialize(*args) @initialized = true end def initialized? @initialized || false end end klass.allocate.initialized? #=> false
Returns true
if the log level allows entries with severity Logger::FATAL to be written, false
otherwise. See Log Level.
Sets the log level to Logger::FATAL. See Log Level.
Equivalent to calling add
with severity Logger::FATAL
.
Invokes the block, setting the block’s parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block.
a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
Note that prc.()
invokes prc.call()
with the parameters given. It’s syntactic sugar to hide “call”.
For procs created using lambda
or ->()
an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new
or Kernel.proc
, extra parameters are silently discarded and missing parameters are set to nil
.
a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
See also Proc#lambda?
.
Invokes the meth with the specified arguments, returning the method’s return value.
m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32
Generates a Continuation
object, which it passes to the associated block. You need to require 'continuation'
before using this method. Performing a cont.call
will cause the callcc
to return (as will falling through the end of the block). The value returned by the callcc
is the value of the block, or the value passed to cont.call
. See class Continuation
for more details. Also see Kernel#throw
for an alternative mechanism for unwinding a call stack.