Return all reachable objects from root.
Prefix and suffix the program filename the same as ruby.
Set Proxy-Authorization: header for “Basic” authorization.
Add the –http-proxy option
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]
Returns the first element in self that is an Array whose first element == obj:
a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.assoc(4) # => [4, 5, 6]
Returns nil if no such element is found.
Related: rassoc.
Returns the first element in self that is an Array whose second element == obj:
a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.rassoc(4) # => [2, 4]
Returns nil if no such element is found.
Related: assoc.
Returns a new Array containing all but 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.drop(0) # => [0, 1, 2, 3, 4, 5] a.drop(1) # => [1, 2, 3, 4, 5] a.drop(2) # => [2, 3, 4, 5]
Prepends the given objects to self:
a = [:foo, 'bar', 2] a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
Array#prepend is an alias for Array#unshift.
Returns the predecessor of self (equivalent to self - 1):
1.pred #=> 0 -1.pred #=> -2
Related: Integer#succ (successor value).
Returns self rounded to the nearest value with a precision of ndigits decimal digits.
When ndigits is negative, the returned value has at least ndigits.abs trailing zeros:
555.round(-1) # => 560 555.round(-2) # => 600 555.round(-3) # => 1000 -555.round(-2) # => -600 555.round(-4) # => 0
Returns self when ndigits is zero or positive.
555.round # => 555 555.round(1) # => 555 555.round(50) # => 555
If keyword argument half is given, and self is equidistant from the two candidate values, the rounding is according to the given half value:
:up or nil: round away from zero:
25.round(-1, half: :up) # => 30 (-25).round(-1, half: :up) # => -30
:down: round toward zero:
25.round(-1, half: :down) # => 20 (-25).round(-1, half: :down) # => -20
:even: round toward the candidate whose last nonzero digit is even:
25.round(-1, half: :even) # => 20 15.round(-1, half: :even) # => 20 (-25).round(-1, half: :even) # => -20
Raises and exception if the value for half is invalid.
Related: Integer#truncate.
Returns true if int has a zero value.
Returns true if zero has a zero value, false otherwise.
Of the Core and Standard Library classes, only Rational and Complex use this implementation.
Returns self if self is not a zero value, nil otherwise; uses method zero? for the evaluation.
The returned self allows the method to be chained:
a = %w[z Bb bB bb BB a aA Aa AA A] a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b } # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
Of the Core and Standard Library classes, Integer, Float, Rational, and Complex use this implementation.
Returns self rounded to the nearest value with a precision of digits decimal digits.
Numeric implements this by converting self to a Float and invoking Float#round.
Interprets the leading substring of self as a string of octal digits (with an optional sign) and returns the corresponding number; returns zero if there is no such leading substring:
'123'.oct # => 83 '-377'.oct # => -255 '0377non-numeric'.oct # => 255 'non-numeric'.oct # => 0
If self starts with 0, radix indicators are honored; see Kernel#Integer.
Related: String#hex.