Results for: "to_proc"

A recommended version for use with a ~> Requirement.

Return a progress reporter object chosen from the current verbosity.

Args

oth

URI or String

Description

Calculates relative path from oth to self.

Usage

require 'uri'

uri = URI.parse('http://my.example.com/main.rbx?page=1')
uri.route_from('http://my.example.com')
#=> #<URI::Generic /main.rbx?page=1>

Returns a proxy URI. The proxy URI is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned.

If the optional parameter env is specified, it is used instead of ENV.

Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are examined, too.

But http_proxy and HTTP_PROXY is treated specially under CGI environment. It’s because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY can be used instead.

MRI specific feature

Return all reachable objects from root.

Prefix and suffix the program filename the same as ruby.

No documentation available

Sets header 'Proxy-Authorization' using the given account and password strings:

req.proxy_basic_auth('my_account', 'my_password')
req['Proxy-Authorization']
# => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
No documentation available

Add the –http-proxy option

No documentation available
No documentation available

Returns a new array formed from self with elements rotated from one end to the other.

With non-negative numeric count, rotates elements from the beginning to the end:

[0, 1, 2, 3].rotate(2)   # => [2, 3, 0, 1]
[0, 1, 2, 3].rotate(2.1) # => [2, 3, 0, 1]

If count is large, uses count % array.size as the count:

[0, 1, 2, 3].rotate(22) # => [2, 3, 0, 1]

With a count of zero, rotates no elements:

[0, 1, 2, 3].rotate(0) # => [0, 1, 2, 3]

With negative numeric count, rotates in the opposite direction, from the end to the beginning:

[0, 1, 2, 3].rotate(-1) # => [3, 0, 1, 2]

If count is small (far from zero), uses count % array.size as the count:

[0, 1, 2, 3].rotate(-21) # => [3, 0, 1, 2]

Related: see Methods for Fetching.

Rotates self in place by moving elements from one end to the other; returns self.

With non-negative numeric count, rotates count elements from the beginning to the end:

[0, 1, 2, 3].rotate!(2)   # => [2, 3, 0, 1]
[0, 1, 2, 3].rotate!(2.1) # => [2, 3, 0, 1]

If count is large, uses count % array.size as the count:

[0, 1, 2, 3].rotate!(21) # => [1, 2, 3, 0]

If count is zero, rotates no elements:

[0, 1, 2, 3].rotate!(0) # => [0, 1, 2, 3]

With a negative numeric count, rotates in the opposite direction, from end to beginning:

[0, 1, 2, 3].rotate!(-1) # => [3, 0, 1, 2]

If count is small (far from zero), uses count % array.size as the count:

[0, 1, 2, 3].rotate!(-21) # => [3, 0, 1, 2]

Related: see Methods for Assigning.

Returns the first element ele in self such that ele is an array and ele[0] == object:

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: Array#rassoc; see also Methods for Fetching.

Returns the first element ele in self such that ele is an array and ele[1] == object:

a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
a.rassoc(4) # => [2, 4]
a.rassoc(5) # => [4, 5, 6]

Returns nil if no such element is found.

Related: Array#assoc; see also Methods for Fetching.

Returns a new array containing all but the first count element of self, where count 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]
a.drop(9) # => []

Related: see Methods for Fetching.

Prepends the given objects to self:

a = [:foo, 'bar', 2]
a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]

Related: Array#shift; see also Methods for Assigning.

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:

Raises and exception if the value for half is invalid.

Related: Integer#truncate.

Returns true if self has a zero value, false otherwise.

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.

Related: zero?

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.

Search took: 8ms  ·  Total Results: 1548