Results for: "match"

Verifies each certificate in chain has signed the following certificate and is valid for the given time.

Verifies that data matches the signature created by public_key and the digest algorithm.

Updates the TarHeader’s checksum

No documentation available
No documentation available

Enumerates trusted certificates.

Delegates to the wrapped source’s fetch_spec method.

Returns the element at Integer offset index; does not modify self.

a = [:foo, 'bar', 2]
a.at(0) # => :foo
a.at(2) # => 2

Adds to array all elements from each Array in other_arrays; returns self:

a = [0, 1]
a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5]

Iterates over array elements.

When a block given, passes each successive array element to the block; returns self:

a = [:foo, 'bar', 2]
a.each {|element|  puts "#{element.class} #{element}" }

Output:

Symbol foo
String bar
Integer 2

Allows the array to be modified during iteration:

a = [:foo, 'bar', 2]
a.each {|element| puts element; a.clear if element.to_s.start_with?('b') }

Output:

foo
bar

When no block given, returns a new Enumerator:

a = [:foo, 'bar', 2]
e = a.each
e # => #<Enumerator: [:foo, "bar", 2]:each>
a1 = e.each {|element|  puts "#{element.class} #{element}" }

Output:

Symbol foo
String bar
Integer 2

Related: each_index, reverse_each.

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]

Calls the block, if given, with each element of self; returns a new Array whose elements are the return values from the block:

a = [:foo, 'bar', 2]
a1 = a.map {|element| element.class }
a1 # => [Symbol, String, Integer]

Returns a new Enumerator if no block given:

a = [:foo, 'bar', 2]
a1 = a.map
a1 # => #<Enumerator: [:foo, "bar", 2]:map>

Array#collect is an alias for Array#map.

Calls the block, if given, with each element; replaces the element with the block’s return value:

a = [:foo, 'bar', 2]
a.map! { |element| element.class } # => [Symbol, String, Integer]

Returns a new Enumerator if no block given:

a = [:foo, 'bar', 2]
a1 = a.map!
a1 # => #<Enumerator: [:foo, "bar", 2]:map!>

Array#collect! is an alias for Array#map!.

Returns one of the following:

When no block is given, each element in self must respond to method <=> with an Integer.

With no argument and no block, returns the element in self having the maximum value per method <=>:

[0, 1, 2].max # => 2

With an argument Integer n and no block, returns a new Array with at most n elements, in descending order per method <=>:

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

When a block is given, the block must return an Integer.

With a block and no argument, calls the block self.size-1 times to compare elements; returns the element having the maximum value per the block:

['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000"

With an argument n and a block, returns a new Array with at most n elements, in descending order per the block:

['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]

Returns a new 2-element Array containing the minimum and maximum values from self, either per method <=> or per a given block:.

When no block is given, each element in self must respond to method <=> with an Integer; returns a new 2-element Array containing the minimum and maximum values from self, per method <=>:

[0, 1, 2].minmax # => [0, 2]

When a block is given, the block must return an Integer; the block is called self.size-1 times to compare elements; returns a new 2-element Array containing the minimum and maximum values from self, per the block:

['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"]

Returns a new Array that is a recursive flattening of self:

With non-negative Integer argument level, flattens recursively through level levels:

a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(0) # => [0, [1, [2, 3], 4], 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(1) # => [0, 1, [2, 3], 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(2) # => [0, 1, 2, 3, 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(3) # => [0, 1, 2, 3, 4, 5]

With no argument, a nil argument, or with negative argument level, flattens all levels:

a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten # => [0, 1, 2, 3, 4, 5]
[0, 1, 2].flatten # => [0, 1, 2]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(-1) # => [0, 1, 2, 3, 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten(-2) # => [0, 1, 2, 3, 4, 5]
[0, 1, 2].flatten(-1) # => [0, 1, 2]

Replaces each nested Array in self with the elements from that Array; returns self if any changes, nil otherwise.

With non-negative Integer argument level, flattens recursively through level levels:

a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten!(1) # => [0, 1, [2, 3], 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten!(2) # => [0, 1, 2, 3, 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten!(3) # => [0, 1, 2, 3, 4, 5]
[0, 1, 2].flatten!(1) # => nil

With no argument, a nil argument, or with negative argument level, flattens all levels:

a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten! # => [0, 1, 2, 3, 4, 5]
[0, 1, 2].flatten! # => nil
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten!(-1) # => [0, 1, 2, 3, 4, 5]
a = [ 0, [ 1, [2, 3], 4 ], 5 ]
a.flatten!(-2) # => [0, 1, 2, 3, 4, 5]
[0, 1, 2].flatten!(-1) # => nil

When invoked with a block, yield all permutations of elements of self; returns self. The order of permutations is indeterminate.

When a block and an in-range positive Integer argument n (0 < n <= self.size) are given, calls the block with all n-tuple permutations of self.

Example:

a = [0, 1, 2]
a.permutation(2) {|permutation| p permutation }

Output:

[0, 1]
[0, 2]
[1, 0]
[1, 2]
[2, 0]
[2, 1]

Another example:

a = [0, 1, 2]
a.permutation(3) {|permutation| p permutation }

Output:

[0, 1, 2]
[0, 2, 1]
[1, 0, 2]
[1, 2, 0]
[2, 0, 1]
[2, 1, 0]

When n is zero, calls the block once with a new empty Array:

a = [0, 1, 2]
a.permutation(0) {|permutation| p permutation }

Output:

[]

When n is out of range (negative or larger than self.size), does not call the block:

a = [0, 1, 2]
a.permutation(-1) {|permutation| fail 'Cannot happen' }
a.permutation(4) {|permutation| fail 'Cannot happen' }

When a block given but no argument, behaves the same as a.permutation(a.size):

a = [0, 1, 2]
a.permutation {|permutation| p permutation }

Output:

[0, 1, 2]
[0, 2, 1]
[1, 0, 2]
[1, 2, 0]
[2, 0, 1]
[2, 1, 0]

Returns a new Enumerator if no block given:

a = [0, 1, 2]
a.permutation # => #<Enumerator: [0, 1, 2]:permutation>
a.permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>

Calls the block, if given, with combinations of elements of self; returns self. The order of combinations is indeterminate.

When a block and an in-range positive Integer argument n (0 < n <= self.size) are given, calls the block with all n-tuple combinations of self.

Example:

a = [0, 1, 2]
a.combination(2) {|combination| p combination }

Output:

[0, 1]
[0, 2]
[1, 2]

Another example:

a = [0, 1, 2]
a.combination(3) {|combination| p combination }

Output:

[0, 1, 2]

When n is zero, calls the block once with a new empty Array:

a = [0, 1, 2]
a1 = a.combination(0) {|combination| p combination }

Output:

[]

When n is out of range (negative or larger than self.size), does not call the block:

a = [0, 1, 2]
a.combination(-1) {|combination| fail 'Cannot happen' }
a.combination(4) {|combination| fail 'Cannot happen' }

Returns a new Enumerator if no block given:

a = [0, 1, 2]
a.combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>

Returns an element from self selected by a binary search. self should be sorted, but this is not checked.

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.

There are two search modes:

The block should not mix the modes by and sometimes returning true or false and sometimes returning a numeric value, but this is not checked.

Find-Minimum Mode

In find-minimum mode, the block always returns true or false. The further requirement (though not checked) is that there are no indexes i and j such that:

In find-minimum mode, method bsearch returns the first element for which the block returns true.

Examples:

a = [0, 4, 7, 10, 12]
a.bsearch {|x| x >= 4 } # => 4
a.bsearch {|x| x >= 6 } # => 7
a.bsearch {|x| x >= -1 } # => 0
a.bsearch {|x| x >= 100 } # => nil

Less formally: the block is such that all false-evaluating elements precede all true-evaluating elements.

These make sense as blocks in find-minimum mode:

a = [0, 4, 7, 10, 12]
a.map {|x| x >= 4 } # => [false, true, true, true, true]
a.map {|x| x >= 6 } # => [false, false, true, true, true]
a.map {|x| x >= -1 } # => [true, true, true, true, true]
a.map {|x| x >= 100 } # => [false, false, false, false, false]

This would not make sense:

a = [0, 4, 7, 10, 12]
a.map {|x| x == 7 } # => [false, false, true, false, false]

Find-Any Mode

In find-any mode, the block always returns a numeric value. The further requirement (though not checked) is that there are no indexes i and j such that:

In find-any mode, method bsearch returns some element for which the block returns zero, or nil if no such element is found.

Examples:

a = [0, 4, 7, 10, 12]
a.bsearch {|element| 7 <=> element } # => 7
a.bsearch {|element| -1 <=> element } # => nil
a.bsearch {|element| 5 <=> element } # => nil
a.bsearch {|element| 15 <=> element } # => nil

Less formally: the block is such that:

These make sense as blocks in find-any mode:

a = [0, 4, 7, 10, 12]
a.map {|element| 7 <=> element } # => [1, 1, 0, -1, -1]
a.map {|element| -1 <=> element } # => [-1, -1, -1, -1, -1]
a.map {|element| 5 <=> element } # => [1, 1, -1, -1, -1]
a.map {|element| 15 <=> element } # => [1, 1, 1, 1, 1]

This would not make sense:

a = [0, 4, 7, 10, 12]
a.map {|element| element <=> 7 } # => [-1, -1, 0, 1, 1]

Returns an enumerator if no block given:

a = [0, 4, 7, 10, 12]
a.bsearch # => #<Enumerator: [0, 4, 7, 10, 12]:bsearch>

Returns a Hash containing implementation-dependent counters inside the VM.

This hash includes information about method/constant cache serials:

{
  :global_constant_state=>481,
  :class_serial=>9029
}

The contents of the hash are implementation specific and may be changed in the future.

This method is only expected to work on C Ruby.

The primary interface to this library. Use to setup delegation when defining your class.

class MyClass < DelegateClass(ClassToDelegateTo) # Step 1
  def initialize
    super(obj_of_ClassToDelegateTo)              # Step 2
  end
end

or:

MyClass = DelegateClass(ClassToDelegateTo) do    # Step 1
  def initialize
    super(obj_of_ClassToDelegateTo)              # Step 2
  end
end

Here’s a sample of use from Tempfile which is really a File object with a few special rules about storage location and when the File should be deleted. That makes for an almost textbook perfect example of how to use delegation.

class Tempfile < DelegateClass(File)
  # constant and class member data initialization...

  def initialize(basename, tmpdir=Dir::tmpdir)
    # build up file path/name in var tmpname...

    @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)

    # ...

    super(@tmpfile)

    # below this point, all methods of File are supported...
  end

  # ...
end
No documentation available

Returns a string containing the character represented by the int‘s value according to encoding.

65.chr    #=> "A"
230.chr   #=> "\xE6"
255.chr(Encoding::UTF_8)   #=> "\u00FF"
Search took: 5ms  ·  Total Results: 1777