Results for: "match"

No documentation available

def child_nodes: () -> Array[nil | Node]

def child_nodes: () -> Array[nil | Node]

def child_nodes: () -> Array[nil | Node]

def child_nodes: () -> Array[nil | Node]

No documentation available

Dispatches a single event for ‘node` to all registered listeners.

def dispatch_once: (Node) -> void

Downloads uri and returns it as a String.

A recommended version for use with a ~> Requirement.

@api private

No documentation available

Calls the block with each repeated permutation of length n of the elements of self; each permutation is an Array; returns self. The order of the permutations is indeterminate.

When a block and a positive Integer argument n are given, calls the block with each n-tuple repeated permutation of the elements of self. The number of permutations is self.size**n.

n = 1:

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

Output:

[0]
[1]
[2]

n = 2:

a.repeated_permutation(2) {|permutation| p permutation }

Output:

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

If n is zero, calls the block once with an empty Array.

If n is negative, does not call the block:

a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' }

Returns a new Enumerator if no block given:

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

Using Enumerators, it’s convenient to show the permutations and counts for some values of n:

e = a.repeated_permutation(0)
e.size # => 1
e.to_a # => [[]]
e = a.repeated_permutation(1)
e.size # => 3
e.to_a # => [[0], [1], [2]]
e = a.repeated_permutation(2)
e.size # => 9
e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]

Calls the block with each repeated combination of length n of the elements of self; each combination is an Array; returns self. The order of the combinations is indeterminate.

When a block and a positive Integer argument n are given, calls the block with each n-tuple repeated combination of the elements of self. The number of combinations is (n+1)(n+2)/2.

n = 1:

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

Output:

[0]
[1]
[2]

n = 2:

a.repeated_combination(2) {|combination| p combination }

Output:

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

If n is zero, calls the block once with an empty Array.

If n is negative, does not call the block:

a.repeated_combination(-1) {|combination| fail 'Cannot happen' }

Returns a new Enumerator if no block given:

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

Using Enumerators, it’s convenient to show the combinations and counts for some values of n:

e = a.repeated_combination(0)
e.size # => 1
e.to_a # => [[]]
e = a.repeated_combination(1)
e.size # => 3
e.to_a # => [[0], [1], [2]]
e = a.repeated_combination(2)
e.size # => 6
e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]]

Calls the given block with each successive character from self; returns self:

'hello'.each_char {|char| print char, ' ' }
print "\n"
'тест'.each_char {|char| print char, ' ' }
print "\n"
'こんにちは'.each_char {|char| print char, ' ' }
print "\n"

Output:

h e l l o
т е с т
    

Returns an enumerator if no block is given.

Like Dir.foreach, except that entries '.' and '..' are not included.

Calls the block with each entry name in self except '.' and '..':

dir = Dir.new('/example')
dir.each_child {|entry_name| p entry_name }

Output:

"config.h"
"lib"
"main.rb"

If no block is given, returns an enumerator.

Returns the locale charmap name. It returns nil if no appropriate information.

Debian GNU/Linux
  LANG=C
    Encoding.locale_charmap  #=> "ANSI_X3.4-1968"
  LANG=ja_JP.EUC-JP
    Encoding.locale_charmap  #=> "EUC-JP"

SunOS 5
  LANG=C
    Encoding.locale_charmap  #=> "646"
  LANG=ja
    Encoding.locale_charmap  #=> "eucJP"

The result is highly platform dependent. So Encoding.find(Encoding.locale_charmap) may cause an error. If you need some encoding object even for unknown locale, Encoding.find(“locale”) can be used.

Calls the given block with each character in the stream; returns self. See Character IO.

f = File.new('t.rus')
a = []
f.each_char {|c| a << c.ord }
a # => [1090, 1077, 1089, 1090]
f.close

Returns an Enumerator if no block is given.

Related: IO#each_byte, IO#each_codepoint.

Returns the object for which the receiver is the singleton class.

Raises an TypeError if the class is not a singleton class.

class Foo; end

Foo.singleton_class.attached_object        #=> Foo
Foo.attached_object                        #=> TypeError: `Foo' is not a singleton class
Foo.new.singleton_class.attached_object    #=> #<Foo:0x000000010491a370>
TrueClass.attached_object                  #=> TypeError: `TrueClass' is not a singleton class
NilClass.attached_object                   #=> TypeError: `NilClass' is not a singleton class

Iterates over the children of the directory (files and subdirectories, not recursive).

It yields Pathname object for each child.

By default, the yielded pathnames will have enough information to access the files.

If you set with_directory to false, then the returned pathnames will contain the filename only.

Pathname("/usr/local").each_child {|f| p f }
#=> #<Pathname:/usr/local/share>
#   #<Pathname:/usr/local/bin>
#   #<Pathname:/usr/local/games>
#   #<Pathname:/usr/local/lib>
#   #<Pathname:/usr/local/include>
#   #<Pathname:/usr/local/sbin>
#   #<Pathname:/usr/local/src>
#   #<Pathname:/usr/local/man>

Pathname("/usr/local").each_child(false) {|f| p f }
#=> #<Pathname:share>
#   #<Pathname:bin>
#   #<Pathname:games>
#   #<Pathname:lib>
#   #<Pathname:include>
#   #<Pathname:sbin>
#   #<Pathname:src>
#   #<Pathname:man>

Note that the results never contain the entries . and .. in the directory because they are not children.

See Pathname#children

With a block given, calls the block with each remaining character in the stream; see Character IO.

With no block given, returns an enumerator.

Returns a new Array containing the values associated with the given keys *keys:

h = {foo: 0, bar: 1, baz: 2}
h.fetch_values(:baz, :foo) # => [2, 0]

Returns a new empty Array if no arguments given.

When a block is given, calls the block with each missing key, treating the block’s return value as the value for that key:

h = {foo: 0, bar: 1, baz: 2}
values = h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s}
values # => [1, 0, "bad", "bam"]

When no block is given, raises an exception if any given key is not found.

Iterates over each character of each file in ARGF.

This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last character of the first file has been returned, the first character of the second file is returned. The ARGF.filename method can be used to determine the name of the file in which the current character appears.

If no block is given, an enumerator is returned instead.

No documentation available
No documentation available
Search took: 11ms  ·  Total Results: 2422