Ensures the root of chain
has a trusted certificate in trust_dir
and the digests of the two certificates match according to digester
Return the 2 dependency objects that conflicted
Returns true
if this gem is installable for the current platform.
Returns true
if this gem is installable for the current platform.
Returns true if this specification is installable on this platform.
Add a certificate to trusted certificate list.
Returns the new string formed by calling method #inspect
on each array element:
a = [:foo, 'bar', 2] a.inspect # => "[:foo, \"bar\", 2]"
Related: see Methods for Converting.
Returns a new array containing each element in self
that is #eql?
to at least one element in each of the given other_arrays
; duplicates are omitted:
[0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
Each element must correctly implement method #hash
.
Order from self
is preserved:
[0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2]
Returns a copy of self
if no arguments are given.
Related: see Methods for Combining.
Returns whether other_array
has at least one element that is #eql?
to some element of self
:
[1, 2, 3].intersect?([3, 4, 5]) # => true [1, 2, 3].intersect?([4, 5, 6]) # => false
Each element must correctly implement method #hash
.
Related: see Methods for Querying.
Inserts the given objects
as elements of self
; returns self
.
When index
is non-negative, inserts objects
before the element at offset index
:
a = ['a', 'b', 'c'] # => ["a", "b", "c"] a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"]
Extends the array if index
is beyond the array (index >= self.size
):
a = ['a', 'b', 'c'] # => ["a", "b", "c"] a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z]
When index
is negative, inserts objects
after the element at offset index + self.size
:
a = ['a', 'b', 'c'] # => ["a", "b", "c"] a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"]
With no objects
given, does nothing:
a = ['a', 'b', 'c'] # => ["a", "b", "c"] a.insert(1) # => ["a", "b", "c"] a.insert(50) # => ["a", "b", "c"] a.insert(-50) # => ["a", "b", "c"]
Raises IndexError
if objects
are given and index
is negative and out of range.
Related: see Methods for Assigning.
Returns the count of elements in self
:
[0, 1, 2].length # => 3 [].length # => 0
Related: see Methods for Querying.
Returns the zero-based integer index of a specified element, or nil
.
With only argument object
given, returns the index of the first element element
for which object == element
:
a = [:foo, 'bar', 2, 'bar'] a.index('bar') # => 1
Returns nil
if no such element found.
With only a block given, calls the block with each successive element; returns the index of the first element for which the block returns a truthy value:
a = [:foo, 'bar', 2, 'bar'] a.index {|element| element == 'bar' } # => 1
Returns nil
if the block never returns a truthy value.
With neither an argument nor a block given, returns a new Enumerator
.
Related: see Methods for Querying.
Returns the new string formed by joining the converted elements of self
; for each element element
:
Converts recursively using element.join(separator)
if element
is a kind_of?(Array)
.
Otherwise, converts using element.to_s
.
With no argument given, joins using the output field separator, $,
:
a = [:foo, 'bar', 2] $, # => nil a.join # => "foobar2"
With string argument separator
given, joins using that separator:
a = [:foo, 'bar', 2] a.join("\n") # => "foo\nbar\n2"
Joins recursively for nested arrays:
a = [:foo, [:bar, [:baz, :bat]]] a.join # => "foobarbazbat"
Related: see Methods for Converting.
Returns a new array that is self
as a transposed matrix:
a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]] a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]]
The elements of self
must all be the same size.
Related: see Methods for Converting.
Returns whether for some element element
in self
, object == element
:
[0, 1, 2].include?(2) # => true [0, 1, 2].include?(2.0) # => true [0, 1, 2].include?(2.1) # => false
Related: see Methods for Querying.
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 a 2-element array containing the minimum-valued and maximum-valued elements from self
; does not modify self
.
With no block given, the minimum and maximum values are determined using method #<=>
:
[1, 0, 3, 2].minmax # => [0, 3]
With a block given, the block must return a numeric; the block is called self.size - 1
times to compare elements; returns the elements having the minimum and maximum values per the block:
['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size } # => ["", "000"]
Related: see Methods for Fetching.
When a block and a positive integer-convertible object argument count
(0 < count <= self.size
) are given, calls the block with each combination of self
of size count
; returns self
:
a = %w[a b c] # => ["a", "b", "c"] a.combination(2) {|combination| p combination } # => ["a", "b", "c"]
Output:
["a", "b"] ["a", "c"] ["b", "c"]
The order of the yielded combinations is not guaranteed.
When count
is zero, calls the block once with a new empty array:
a.combination(0) {|combination| p combination } [].combination(0) {|combination| p combination }
Output:
[] []
When count
is negative or larger than self.size
and self
is non-empty, does not call the block:
a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"] a.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
With no block given, returns a new Enumerator
.
Related: Array#permutation
; see also Methods for Iterating.