Return an array of IndexSpecification objects matching DependencyRequest req
.
Returns an array of IndexSpecification objects matching DependencyRequest req
.
Returns an Array
of IndexSpecification objects matching the DependencyRequest req
.
The find_all
method must be implemented. It returns all Resolver Specification objects matching the given DependencyRequest req
.
Returns an Array
of VendorSpecification objects matching the DependencyRequest req
.
Returns a new Array formed from self
with elements rotated from one end to the other.
When no argument given, returns a new Array that is like self
, except that the first element has been rotated to the last position:
a = [:foo, 'bar', 2, 'bar'] a1 = a.rotate a1 # => ["bar", 2, "bar", :foo]
When given a non-negative Integer
count
, returns a new Array with count
elements rotated from the beginning to the end:
a = [:foo, 'bar', 2] a1 = a.rotate(2) a1 # => [2, :foo, "bar"]
If count
is large, uses count % array.size
as the count:
a = [:foo, 'bar', 2] a1 = a.rotate(20) a1 # => [2, :foo, "bar"]
If count
is zero, returns a copy of self
, unmodified:
a = [:foo, 'bar', 2] a1 = a.rotate(0) a1 # => [:foo, "bar", 2]
When given a negative Integer
count
, rotates in the opposite direction, from end to beginning:
a = [:foo, 'bar', 2] a1 = a.rotate(-2) a1 # => ["bar", 2, :foo]
If count
is small (far from zero), uses count % array.size
as the count:
a = [:foo, 'bar', 2] a1 = a.rotate(-5) a1 # => ["bar", 2, :foo]
Rotates self
in place by moving elements from one end to the other; returns self
.
When no argument given, rotates the first element to the last position:
a = [:foo, 'bar', 2, 'bar'] a.rotate! # => ["bar", 2, "bar", :foo]
When given a non-negative Integer
count
, rotates count
elements from the beginning to the end:
a = [:foo, 'bar', 2] a.rotate!(2) a # => [2, :foo, "bar"]
If count
is large, uses count % array.size
as the count:
a = [:foo, 'bar', 2] a.rotate!(20) a # => [2, :foo, "bar"]
If count
is zero, returns self
unmodified:
a = [:foo, 'bar', 2] a.rotate!(0) a # => [:foo, "bar", 2]
When given a negative Integer
count
, rotates in the opposite direction, from end to beginning:
a = [:foo, 'bar', 2] a.rotate!(-2) a # => ["bar", 2, :foo]
If count
is small (far from zero), uses count % array.size
as the count:
a = [:foo, 'bar', 2] a.rotate!(-5) a # => ["bar", 2, :foo]
Calls the block, if given, with each element of self
; returns a new Array whose elements are the return values from the block:
a = [:foo, 'bar', 2] a1 = a.map {|element| element.class } a1 # => [Symbol, String, Integer]
Returns a new Enumerator
if no block given:
a = [:foo, 'bar', 2] a1 = a.map a1 # => #<Enumerator: [:foo, "bar", 2]:map>
Calls the block, if given, with each element; replaces the element with the block’s return value:
a = [:foo, 'bar', 2] a.map! { |element| element.class } # => [Symbol, String, Integer]
Returns a new Enumerator
if no block given:
a = [:foo, 'bar', 2] a1 = a.map! a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
Replaces specified elements in self
with specified objects; returns self
.
With argument obj
and no block given, replaces all elements with that one object:
a = ['a', 'b', 'c', 'd'] a # => ["a", "b", "c", "d"] a.fill(:X) # => [:X, :X, :X, :X]
With arguments obj
and Integer
start
, and no block given, replaces elements based on the given start.
If start
is in range (0 <= start < array.size
), replaces all elements from offset start
through the end:
a = ['a', 'b', 'c', 'd'] a.fill(:X, 2) # => ["a", "b", :X, :X]
If start
is too large (start >= array.size
), does nothing:
a = ['a', 'b', 'c', 'd'] a.fill(:X, 4) # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5) # => ["a", "b", "c", "d"]
If start
is negative, counts from the end (starting index is start + array.size
):
a = ['a', 'b', 'c', 'd'] a.fill(:X, -2) # => ["a", "b", :X, :X]
If start
is too small (less than and far from zero), replaces all elements:
a = ['a', 'b', 'c', 'd'] a.fill(:X, -6) # => [:X, :X, :X, :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, -50) # => [:X, :X, :X, :X]
With arguments obj
, Integer
start
, and Integer
length
, and no block given, replaces elements based on the given start
and length
.
If start
is in range, replaces length
elements beginning at offset start
:
a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 1) # => ["a", :X, "c", "d"]
If start
is negative, counts from the end:
a = ['a', 'b', 'c', 'd'] a.fill(:X, -2, 1) # => ["a", "b", :X, "d"]
If start
is large (start >= array.size
), extends self
with nil
:
a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 2) # => ["a", "b", "c", "d", nil, :X, :X]
If length
is zero or negative, replaces no elements:
a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 0) # => ["a", "b", "c", "d"] a.fill(:X, 1, -1) # => ["a", "b", "c", "d"]
With arguments obj
and Range
range
, and no block given, replaces elements based on the given range.
If the range is positive and ascending (0 < range.begin <= range.end
), replaces elements from range.begin
to range.end
:
a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..1)) # => ["a", :X, "c", "d"]
If range.first
is negative, replaces no elements:
a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..1)) # => ["a", "b", "c", "d"]
If range.last
is negative, counts from the end:
a = ['a', 'b', 'c', 'd'] a.fill(:X, (0..-2)) # => [:X, :X, :X, "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..-2)) # => ["a", :X, :X, "d"]
If range.last
and range.last
are both negative, both count from the end of the array:
a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..-1)) # => ["a", "b", "c", :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, (-2..-2)) # => ["a", "b", :X, "d"]
With no arguments and a block given, calls the block with each index; replaces the corresponding element with the block’s return value:
a = ['a', 'b', 'c', 'd'] a.fill { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"]
With argument start
and a block given, calls the block with each index from offset start
to the end; replaces the corresponding element with the block’s return value.
If start is in range (0 <= start < array.size
), replaces from offset start
to the end:
a = ['a', 'b', 'c', 'd'] a.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"]
If start
is too large(start >= array.size
), does nothing:
a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
If start
is negative, counts from the end:
a = ['a', 'b', 'c', 'd'] a.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"]
If start is too small (start <= -array.size
, replaces all elements:
a = ['a', 'b', 'c', 'd'] a.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-50) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"]
With arguments start
and length
, and a block given, calls the block for each index specified by start length; replaces the corresponding element with the block’s return value.
If start
is in range, replaces length
elements beginning at offset start
:
a = ['a', 'b', 'c', 'd'] a.fill(1, 1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"]
If start is negative, counts from the end:
a = ['a', 'b', 'c', 'd'] a.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"]
If start
is large (start >= array.size
), extends self
with nil
:
a = ['a', 'b', 'c', 'd'] a.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(5, 2) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil, "new_5", "new_6"]
If length
is zero or less, replaces no elements:
a = ['a', 'b', 'c', 'd'] a.fill(1, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] a.fill(1, -1) { |index| "new_#{index}" } # => ["a", "b", "c", "d"]
With arguments obj
and range
, and a block given, calls the block with each index in the given range; replaces the corresponding element with the block’s return value.
If the range is positive and ascending (range 0 < range.begin <= range.end
, replaces elements from range.begin
to range.end
:
a = ['a', 'b', 'c', 'd'] a.fill(1..1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"]
If range.first
is negative, does nothing:
a = ['a', 'b', 'c', 'd'] a.fill(-1..1) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
If range.last
is negative, counts from the end:
a = ['a', 'b', 'c', 'd'] a.fill(0..-2) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "d"] a = ['a', 'b', 'c', 'd'] a.fill(1..-2) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "d"]
If range.first
and range.last
are both negative, both count from the end:
a = ['a', 'b', 'c', 'd'] a.fill(-1..-1) { |index| "new_#{index}" } # => ["a", "b", "c", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-2..-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"]
When invoked with a block, yield all permutations of elements of self
; returns self
. The order of permutations is indeterminate.
When a block and an in-range positive Integer
argument n
(0 < n <= self.size
) are given, calls the block with all n
-tuple permutations of self
.
Example:
a = [0, 1, 2] a.permutation(2) {|permutation| p permutation }
Output:
[0, 1] [0, 2] [1, 0] [1, 2] [2, 0] [2, 1]
Another example:
a = [0, 1, 2] a.permutation(3) {|permutation| p permutation }
Output:
[0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0]
When n
is zero, calls the block once with a new empty Array:
a = [0, 1, 2] a.permutation(0) {|permutation| p permutation }
Output:
[]
When n
is out of range (negative or larger than self.size
), does not call the block:
a = [0, 1, 2] a.permutation(-1) {|permutation| fail 'Cannot happen' } a.permutation(4) {|permutation| fail 'Cannot happen' }
When a block given but no argument, behaves the same as a.permutation(a.size)
:
a = [0, 1, 2] a.permutation {|permutation| p permutation }
Output:
[0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0]
Returns a new Enumerator
if no block given:
a = [0, 1, 2] a.permutation # => #<Enumerator: [0, 1, 2]:permutation> a.permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>
Returns a new Array containing the first n
element of self
, where n
is a non-negative Integer
; does not modify self
.
Examples:
a = [0, 1, 2, 3, 4, 5] a.take(1) # => [0] a.take(2) # => [0, 1] a.take(50) # => [0, 1, 2, 3, 4, 5] a # => [0, 1, 2, 3, 4, 5]
Builds a command line string from an argument list array
joining all elements escaped for the Bourne shell and separated by a space.
See Shellwords.shelljoin
for details.
Returns a Hash
containing implementation-dependent counters inside the VM.
This hash includes information about method/constant caches:
{ :constant_cache_invalidations=>2, :constant_cache_misses=>14, :global_cvar_state=>27 }
If USE_DEBUG_COUNTER
is enabled, debug counters will be included.
The contents of the hash are implementation specific and may be changed in the future.
This method is only expected to work on C Ruby.
Returns the value as a rational. The optional argument eps
is always ignored.
Return the class or module refined by the receiver.
module M refine String do end end M.refinements[0].target # => String
Returns a new Complex object formed from the arguments, each of which must be an instance of Numeric
, or an instance of one of its subclasses: Complex, Float
, Integer
, Rational
; see Rectangular Coordinates:
Complex.rect(3) # => (3+0i) Complex.rect(3, Math::PI) # => (3+3.141592653589793i) Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
Complex.rectangular is an alias for Complex.rect.
Returns the real value for self
:
Complex(7).real #=> 7 Complex(9, -4).real #=> 9
If self
was created with polar coordinates, the returned value is computed, and may be inexact:
Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.
Returns the array [self.real, self.imag]
:
Complex.rect(1, 2).rect # => [1, 2]
If self
was created with polar coordinates, the returned value is computed, and may be inexact:
Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]
Complex#rectangular
is an alias for Complex#rect
.
Returns false
; for compatibility with Numeric#real?
.
Returns a Rational
object whose value is exactly or approximately equivalent to that of self.real
.
With no argument epsilon
given, returns a Rational object whose value is exactly equal to that of self.real.rationalize
:
Complex(1, 0).rationalize # => (1/1) Complex(1, Rational(0, 1)).rationalize # => (1/1) Complex(3.14159, 0).rationalize # => (314159/100000)
With argument epsilon
given, returns a Rational object whose value is exactly or approximately equal to that of self.real
to the given precision:
Complex(3.14159, 0).rationalize(0.1) # => (16/5) Complex(3.14159, 0).rationalize(0.01) # => (22/7) Complex(3.14159, 0).rationalize(0.001) # => (201/64) Complex(3.14159, 0).rationalize(0.0001) # => (333/106) Complex(3.14159, 0).rationalize(0.00001) # => (355/113) Complex(3.14159, 0).rationalize(0.000001) # => (7433/2366) Complex(3.14159, 0).rationalize(0.0000001) # => (9208/2931) Complex(3.14159, 0).rationalize(0.00000001) # => (47460/15107) Complex(3.14159, 0).rationalize(0.000000001) # => (76149/24239) Complex(3.14159, 0).rationalize(0.0000000001) # => (314159/100000) Complex(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624)
Related: Complex#to_r
.
Returns zero as a Rational:
nil.rationalize # => (0/1)
Argument eps
is ignored.
Returns array [self, 0]
.
Returns true
if self
is a real number (i.e. not Complex
).