module IN
contains ARPA Internet specific RRs.
Common implementation for SVCB-compatible resource records.
This is similar to PrettyPrint::format
but the result has no breaks.
maxwidth
, newline
and genspace
are ignored.
The invocation of breakable
in the block doesn’t break a line and is treated as just an invocation of text
.
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)
Create a new InterpolatedMatchLastLineNode
node
Returns one of the following:
The maximum-valued element from self
.
A new Array of maximum-valued elements selected from self
.
When no block is given, each element in self
must respond to method <=>
with an Integer
.
With no argument and no block, returns the element in self
having the maximum value per method <=>
:
[0, 1, 2].max # => 2
With an argument Integer
n
and no block, returns a new Array with at most n
elements, in descending order per method <=>
:
[0, 1, 2, 3].max(3) # => [3, 2, 1] [0, 1, 2, 3].max(6) # => [3, 2, 1, 0]
When a block is given, the block must return an Integer
.
With a block and no argument, calls the block self.size-1
times to compare elements; returns the element having the maximum value per the block:
['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000"
With an argument n
and a block, returns a new Array with at most n
elements, in descending order per the block:
['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
Returns one of the following:
The minimum-valued element from self
.
A new Array of minimum-valued elements selected from self
.
When no block is given, each element in self
must respond to method <=>
with an Integer
.
With no argument and no block, returns the element in self
having the minimum value per method <=>
:
[0, 1, 2].min # => 0
With Integer
argument n
and no block, returns a new Array with at most n
elements, in ascending order per method <=>
:
[0, 1, 2, 3].min(3) # => [0, 1, 2] [0, 1, 2, 3].min(6) # => [0, 1, 2, 3]
When a block is given, the block must return an Integer
.
With a block and no argument, calls the block self.size-1
times to compare elements; returns the element having the minimum value per the block:
['0', '00', '000'].min { |a, b| a.size <=> b.size } # => "0"
With an argument n
and a block, returns a new Array with at most n
elements, in ascending order per the block:
['0', '00', '000'].min(2) {|a, b| a.size <=> b.size } # => ["0", "00"]
Returns the remainder after dividing self
by other
.
Examples:
11.remainder(4) # => 3 11.remainder(-4) # => 3 -11.remainder(4) # => -3 -11.remainder(-4) # => -3 12.remainder(4) # => 0 12.remainder(-4) # => 0 -12.remainder(4) # => 0 -12.remainder(-4) # => 0 13.remainder(4.0) # => 1.0 13.remainder(Rational(4, 1)) # => (1/1)
Returns 1
.
Returns the imaginary value for self
:
Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4
If self
was created with polar coordinates, the returned value is computed, and may be inexact:
Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
Returns the denominator of self
, which is the least common multiple of self.real.denominator
and self.imag.denominator
:
Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
Note that n.denominator
of a non-rational numeric is 1
.
Related: Complex#numerator
.
Returns 1
if either self.real.infinite?
or self.imag.infinite?
is true, nil
otherwise:
Complex(Float::INFINITY, 0).infinite? # => 1 Complex(1, 1).infinite? # => nil
Related: Numeric#infinite?
, Float#infinite?
.
Returns the remainder after dividing self
by other
.
Of the Core and Standard Library classes, only Float
and Rational
use this implementation.
Examples:
11.0.remainder(4) # => 3.0 11.0.remainder(-4) # => 3.0 -11.0.remainder(4) # => -3.0 -11.0.remainder(-4) # => -3.0 12.0.remainder(4) # => 0.0 12.0.remainder(-4) # => 0.0 -12.0.remainder(4) # => -0.0 -12.0.remainder(-4) # => -0.0 13.0.remainder(4.0) # => 1.0 13.0.remainder(Rational(4, 1)) # => 1.0 Rational(13, 1).remainder(4) # => (1/1) Rational(13, 1).remainder(-4) # => (1/1) Rational(-13, 1).remainder(4) # => (-1/1) Rational(-13, 1).remainder(-4) # => (-1/1)
Returns nil
, -1, or 1 depending on whether self
is finite, -Infinity
, or +Infinity
.