Returns the destination encoding name as a string.
Returns the destination encoding name as a string.
Returns the position that self
holds in its parent’s array, indexed from 1.
Returns true if other
is a subdomain.
Example:
domain = Resolv::DNS::Name.create("y.z") p Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true p Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true p Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false
Every method call is forwarded to the XML-RPC server defined in XMLRPC::Client::Proxy#new.
Note: Inherited methods from class Object
cannot be used as XML-RPC names, because they get around method_missing
.
Creates a string representation of self
.
[ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]"
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 the index of the first object in ary
such that the object is ==
to obj
.
If a block is given instead of an argument, returns the index of the first object for which the block returns true
. Returns nil
if no match is found.
See also Array#rindex
.
An Enumerator
is returned if neither a block nor argument is given.
a = [ "a", "b", "c" ] a.index("b") #=> 1 a.index("z") #=> nil a.index { |x| x == "b" } #=> 1
Returns the index of the last object in self
==
to obj
.
If a block is given instead of an argument, returns the index of the first object for which the block returns true
, starting from the last object.
Returns nil
if no match is found.
See also Array#index
.
If neither block nor argument is given, an Enumerator
is returned instead.
a = [ "a", "b", "b", "b", "c" ] a.rindex("b") #=> 3 a.rindex("z") #=> nil a.rindex { |x| x == "b" } #=> 3
Returns a string created by converting each element of the array to a string, separated by the given separator
. If the separator
is nil
, it uses current $,. If both the separator
and $, are nil, it uses empty string.
[ "a", "b", "c" ].join #=> "abc" [ "a", "b", "c" ].join("-") #=> "a-b-c"
Invokes the given block once for each element of self
.
Creates a new array containing the values returned by the block.
See also Enumerable#collect
.
If no block is given, an Enumerator
is returned instead.
a = [ "a", "b", "c", "d" ] a.collect { |x| x + "!" } #=> ["a!", "b!", "c!", "d!"] a.map.with_index { |x, i| x * i } #=> ["", "b", "cc", "ddd"] a #=> ["a", "b", "c", "d"]
Invokes the given block once for each element of self
, replacing the element with the value returned by the block.
See also Enumerable#collect
.
If no block is given, an Enumerator
is returned instead.
a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] a.collect!.with_index {|x, i| x[0...i] } a #=> ["", "b", "c!", "d!"]
Returns true
if the given object
is present in self
(that is, if any element ==
object
), otherwise returns false
.
a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false
When invoked with a block, yields all combinations of length n
of elements from the array and then returns the array itself.
The implementation makes no guarantees about the order in which the combinations are yielded.
If no block is given, an Enumerator
is returned instead.
Examples:
a = [1, 2, 3, 4] a.combination(1).to_a #=> [[1],[2],[3],[4]] a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] a.combination(4).to_a #=> [[1,2,3,4]] a.combination(0).to_a #=> [[]] # one combination of length 0 a.combination(5).to_a #=> [] # no combinations of length 5
Builds a command line string from an argument list array
joining all elements escaped for the Bourne shell and separated by a space.
See Shellwords.shelljoin
for details.
Returns the absolute value of big.
-1234567890987654321.abs #=> 1234567890987654321
Returns a string containing the representation of big radix base (2 through 36).
12345654321.to_s #=> "12345654321" 12345654321.to_s(2) #=> "1011011111110110111011110000110001" 12345654321.to_s(8) #=> "133766736061" 12345654321.to_s(16) #=> "2dfdbbc31" 78546939656932.to_s(36) #=> "rubyrules"