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)
Returns one of the following:
The maximum-valued element from self.
A new array of maximum-valued elements from self.
Does not modify self.
With no block given, each element in self must respond to method <=> with a numeric.
With no argument and no block, returns the element in self having the maximum value per method <=>:
[1, 0, 3, 2].max # => 3
With non-negative numeric argument count and no block, returns a new array with at most count elements, in descending order, per method <=>:
[1, 0, 3, 2].max(3) # => [3, 2, 1] [1, 0, 3, 2].max(3.0) # => [3, 2, 1] [1, 0, 3, 2].max(9) # => [3, 2, 1, 0] [1, 0, 3, 2].max(0) # => []
With a block given, the block must return a numeric.
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', '', '000', '00'].max {|a, b| a.size <=> b.size } # => "000"
With non-negative numeric argument count and a block, returns a new array with at most count elements, in descending order, per the block:
['0', '', '000', '00'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
Related: see Methods for Fetching.
Returns one of the following:
The minimum-valued element from self.
A new array of minimum-valued elements from self.
Does not modify self.
With no block given, each element in self must respond to method <=> with a numeric.
With no argument and no block, returns the element in self having the minimum value per method <=>:
[1, 0, 3, 2].min # => 0
With non-negative numeric argument count and no block, returns a new array with at most count elements, in ascending order, per method <=>:
[1, 0, 3, 2].min(3) # => [0, 1, 2] [1, 0, 3, 2].min(3.0) # => [0, 1, 2] [1, 0, 3, 2].min(9) # => [0, 1, 2, 3] [1, 0, 3, 2].min(0) # => []
With a block given, the block must return a numeric.
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', '', '000', '00'].min {|a, b| a.size <=> b.size } # => ""
With non-negative numeric argument count and a block, returns a new array with at most count elements, in ascending order, per the block:
['0', '', '000', '00'].min(2) {|a, b| a.size <=> b.size } # => ["", "0"]
Related: see Methods for Fetching.
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.rect(7).imag # => 0 Complex.rect(9, -4).imag # => -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.rect(Float::INFINITY, 0).infinite? # => 1 Complex.rect(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.
Returns zero.
Returns the denominator (always positive).
Returns:
1, if self is Infinity.
-1 if self is -Infinity.
nil, otherwise.
Examples:
f = 1.0/0.0 # => Infinity f.infinite? # => 1 f = -1.0/0.0 # => -Infinity f.infinite? # => -1 f = 1.0 # => 1.0 f.infinite? # => nil f = 0.0/0.0 # => NaN f.infinite? # => nil
Returns the denominator (always positive). The result is machine dependent.
See also Float#numerator.
Returns true if path matches against pattern. The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters:
*Matches any file. Can be restricted by other values in the glob. Equivalent to /.*/x in regexp.
*Matches all regular files
c*Matches all files beginning with c
*cMatches all files ending with c
*c*Matches all files that have c in them (including at the beginning or end).
To match hidden files (that start with a .) set the File::FNM_DOTMATCH flag.
**Matches directories recursively or files expansively.
?Matches any one character. Equivalent to /.{1}/ in regexp.
[set]Matches any one character in set. Behaves exactly like character sets in Regexp, including set negation ([^a-z]).
\Escapes the next metacharacter.
{a,b}Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled. Behaves like a Regexp union ((?:a|b)).
flags is a bitwise OR of the FNM_XXX constants. The same glob pattern and flags are used by Dir::glob.
Examples:
File.fnmatch('cat', 'cat') #=> true # match entire string File.fnmatch('cat', 'category') #=> false # only match partial string File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character File.fnmatch('c??t', 'cat') #=> false # ditto File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!') File.fnmatch('cat', 'CAT') #=> false # case sensitive File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. File.fnmatch('.*', '.profile') #=> true File.fnmatch('**/*.rb', 'main.rb') #=> false File.fnmatch('**/*.rb', './main.rb') #=> false File.fnmatch('**/*.rb', 'lib/song.rb') #=> true File.fnmatch('**.rb', 'main.rb') #=> true File.fnmatch('**.rb', './main.rb') #=> false File.fnmatch('**.rb', 'lib/song.rb') #=> true File.fnmatch('*', 'dave/.profile') #=> true File.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch('**/foo', '/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch('**/foo', 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
Returns false
Returns the integer minute of the hour for self, in range (0..59):
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.min # => 4