Git binary path
Builds extensions. Valid types of extensions are extconf.rb files, configure scripts and rakefiles or mkrf_conf files.
Returns the path to the trusted certificate
Returns true
@return [Symbol] The name of the action.
Adds the given action to the log, running the action @param [DependencyGraph] graph @param [Action] action @return The value returned by ‘action.up`
Ends the resolution process @return [void]
Appends the elements of other_ary
s to self
.
[ "a", "b" ].concat( ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat( ["b"], ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat #=> [ "a" ] a = [ 1, 2, 3 ] a.concat( [ 4, 5 ]) a #=> [ 1, 2, 3, 4, 5 ] a = [ 1, 2 ] a.concat(a, a) #=> [1, 2, 1, 2, 1, 2]
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 created by sorting self
.
Comparisons for the sort will be done using the <=>
operator or using an optional code block.
The block must implement a comparison between a
and b
and return an integer less than 0 when b
follows a
, 0
when a
and b
are equivalent, or an integer greater than 0 when a
follows b
.
The result is not guaranteed to be stable. When the comparison of two elements returns 0
, the order of the elements is unpredictable.
ary = [ "d", "a", "e", "c", "b" ] ary.sort #=> ["a", "b", "c", "d", "e"] ary.sort {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"]
To produce the reverse order, the following can also be used (and may be faster):
ary.sort.reverse! #=> ["e", "d", "c", "b", "a"]
See also Enumerable#sort_by
.
Sorts self
in place.
Comparisons for the sort will be done using the <=>
operator or using an optional code block.
The block must implement a comparison between a
and b
and return an integer less than 0 when b
follows a
, 0
when a
and b
are equivalent, or an integer greater than 0 when a
follows b
.
The result is not guaranteed to be stable. When the comparison of two elements returns 0
, the order of the elements is unpredictable.
ary = [ "d", "a", "e", "c", "b" ] ary.sort! #=> ["a", "b", "c", "d", "e"] ary.sort! {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"]
See also Enumerable#sort_by
.
Returns a copy of self
with all nil
elements removed.
[ "a", nil, "b", nil, "c", nil ].compact #=> [ "a", "b", "c" ]
Removes nil
elements from the array.
Returns nil
if no changes were made, otherwise returns the array.
[ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ] [ "a", "b", "c" ].compact! #=> nil
By using binary search, finds a value from this array which meets the given condition in O(log n) where n is the size of the array.
You can use this method in two modes: a find-minimum mode and a find-any mode. In either case, the elements of the array must be monotone (or sorted) with respect to the block.
In find-minimum mode (this is a good choice for typical use cases), the block must always return true or false, and there must be an index i (0 <= i <= ary.size) so that:
the block returns false for any element whose index is less than i, and
the block returns true for any element whose index is greater than or equal to i.
This method returns the i-th element. If i is equal to ary.size, it returns nil.
ary = [0, 4, 7, 10, 12] ary.bsearch {|x| x >= 4 } #=> 4 ary.bsearch {|x| x >= 6 } #=> 7 ary.bsearch {|x| x >= -1 } #=> 0 ary.bsearch {|x| x >= 100 } #=> nil
In find-any mode (this behaves like libc’s bsearch(3)), the block must always return a number, and there must be two indices i and j (0 <= i <= j <= ary.size) so that:
the block returns a positive number for ary if 0 <= k < i,
the block returns zero for ary if i <= k < j, and
the block returns a negative number for ary if j <= k < ary.size.
Under this condition, this method returns any element whose index is within i…j. If i is equal to j (i.e., there is no element that satisfies the block), this method returns nil.
ary = [0, 4, 7, 10, 12] # try to find v such that 4 <= v < 8 ary.bsearch {|x| 1 - x / 4 } #=> 4 or 7 # try to find v such that 8 <= v < 10 ary.bsearch {|x| 4 - x / 2 } #=> nil
You must not mix the two modes at a time; the block must always return either true/false, or always return a number. It is undefined which value is actually picked up at each iteration.
See also Enumerable#none?
See also Enumerable#one?