Loads the given certificate_file
Get all [gem, version] from the command line.
An argument in the form gem:ver is pull apart into the gen name and version, respectively.
Array
Difference
Returns a new array that is a copy of the original array, removing all occurrences of any item that also appear in other_ary
. The order is preserved from the original array.
It compares elements using their hash
and eql?
methods for efficiency.
[ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ]
Note that while 1 and 2 were only present once in the array argument, and were present twice in the receiver array, all occurrences of each Integer
are removed in the returned array.
Multiple array arguments can be supplied and all occurrences of any element in those supplied arrays that match the receiver will be removed from the returned array.
[ 1, 'c', :s, 'yep' ].difference([ 1 ], [ 'a', 'c' ]) #=> [ :s, "yep" ]
If you need set-like behavior, see the library class Set
.
See also Array#-
.
Set
Intersection — Returns a new array containing unique elements common to self
and other_ary
s. Order is preserved from the original array.
It compares elements using their hash
and eql?
methods for efficiency.
[ 1, 1, 3, 5 ].intersection([ 3, 2, 1 ]) # => [ 1, 3 ] [ "a", "b", "z" ].intersection([ "a", "b", "c" ], [ "b" ]) # => [ "b" ] [ "a" ].intersection #=> [ "a" ]
See also Array#&
.
Inserts the given values before the element with the given index
.
Negative indices count backwards from the end of the array, where -1
is the last element. If a negative index is used, the given values will be inserted after that element, so using an index of -1
will insert the values at the end of the array.
a = %w{ a b c d } a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
Returns a new array containing self
‘s elements in reverse order.
[ "a", "b", "c" ].reverse #=> ["c", "b", "a"] [ 1 ].reverse #=> [1]
Reverses self
in place.
a = [ "a", "b", "c" ] a.reverse! #=> ["c", "b", "a"] a #=> ["c", "b", "a"]
Returns a new array containing all elements of ary
for which the given block
returns a true value.
If no block is given, an Enumerator
is returned instead.
[1,2,3,4,5].select {|num| num.even? } #=> [2, 4] a = %w[ a b c d e f ] a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"]
See also Enumerable#select
.
Array#filter
is an alias for Array#select
.
Invokes the given block passing in successive elements from self
, deleting elements for which the block returns a false
value.
The array may not be changed instantly every time the block is called.
If changes were made, it will return self
, otherwise it returns nil
.
If no block is given, an Enumerator
is returned instead.
See also Array#keep_if
.
Array#filter!
is an alias for Array#select!
.
When invoked with a block, yield all permutations of length n
of the elements of the array, then return the array itself.
If n
is not specified, yield all permutations of all elements.
The implementation makes no guarantees about the order in which the permutations are yielded.
If no block is given, an Enumerator
is returned instead.
Examples:
a = [1, 2, 3] a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(1).to_a #=> [[1],[2],[3]] a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]] a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] a.permutation(0).to_a #=> [[]] # one permutation of length 0 a.permutation(4).to_a #=> [] # no permutations of length 4
provides a unified clone
operation, for REXML::XPathParser
to use across multiple Object+ types