Results for: "Dir.chdir"

@param [Conflict] conflict @return [Array] minimal array of requirements that would cause the passed

conflict to occur.

@param [Object] requirement we wish to check @param [Array] possible_binding_requirements array of requirements @param [Array] possibilities array of possibilities the requirements will be used to filter @return [Boolean] whether or not the given requirement is required to filter

out all elements of the array of possibilities.

@return [Array<Object>] all of the requirements that required

this vertex

(see Gem::Resolver::Molinillo::ResolutionState#requirements)

(see Gem::Resolver::Molinillo::ResolutionState#requirement)

No documentation available
No documentation available

Iterates over array indexes.

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

a = [:foo, 'bar', 2]
a.each_index {|index|  puts "#{index} #{a[index]}" }

Output:

0 foo
1 bar
2 2

Allows the array to be modified during iteration:

a = [:foo, 'bar', 2]
a.each_index {|index| puts index; a.clear if index > 0 }

Output:

0
1

When no block given, returns a new Enumerator:

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

Output:

0 foo
1 bar
2 2

Related: each, reverse_each.

Iterates backwards over array elements.

When a block given, passes, in reverse order, each element to the block; returns self:

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

Output:

Integer 2
String bar
Symbol foo

Allows the array to be modified during iteration:

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

Output:

2
bar

When no block given, returns a new Enumerator:

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

Output:

Integer 2
String bar
Symbol foo

Related: each, each_index.

Searches self as described at method bsearch, but returns the index of the found element instead of the element itself.

No documentation available

With a block given, forms the substrings (“lines”) that are the result of splitting self at each occurrence of the given line separator line_sep; passes each line to the block; returns self:

s = <<~EOT
This is the first line.
This is line two.

This is line four.
This is line five.
EOT

s.each_line {|line| p line }

Output:

"This is the first line.\n"
"This is line two.\n"
"\n"
"This is line four.\n"
"This is line five.\n"

With a different line_sep:

s.each_line(' is ') {|line| p line }

Output:

"This is "
"the first line.\nThis is "
"line two.\n\nThis is "
"line four.\nThis is "
"line five.\n"

With chomp as true, removes the trailing line_sep from each line:

s.each_line(chomp: true) {|line| p line }

Output:

"This is the first line."
"This is line two."
""
"This is line four."
"This is line five."

With an empty string as line_sep, forms and passes “paragraphs” by splitting at each occurrence of two or more newlines:

s.each_line('') {|line| p line }

Output:

"This is the first line.\nThis is line two.\n\n"
"This is line four.\nThis is line five.\n"

With no block given, returns an enumerator.

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

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

Output:

104 101 108 108 111
209 130 208 181 209 129 209 130
227 129 147 227 130 147 227 129 171 227 129 161 227 129 175

Returns an enumerator if no block is given.

Calls the given block with each successive codepoint from self; each codepoint is the integer value for a character; returns self:

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

Output:

104 101 108 108 111
1090 1077 1089 1090
12371 12435 12395 12385 12399

Returns an enumerator if no block is given.

Sets the Fiber scheduler for the current thread. If the scheduler is set, non-blocking fibers (created by Fiber.new with blocking: false, or by Fiber.schedule) call that scheduler’s hook methods on potentially blocking operations, and the current thread will call scheduler’s close method on finalization (allowing the scheduler to properly manage all non-finished fibers).

scheduler can be an object of any class corresponding to Fiber::Scheduler. Its implementation is up to the user.

See also the “Non-blocking fibers” section in class docs.

Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler if and only if the current fiber is non-blocking.

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.

Return the accept character set for all new CGI instances.

Set the accept character set for all new CGI instances.

Calls the block with each remaining line read from the stream; returns self. Does nothing if already at end-of-stream; See Line IO.

With no arguments given, reads lines as determined by line separator $/:

f = File.new('t.txt')
f.each_line {|line| p line }
f.each_line {|line| fail 'Cannot happen' }
f.close

Output:

"First line\n"
"Second line\n"
"\n"
"Fourth line\n"
"Fifth line\n"

With only string argument sep given, reads lines as determined by line separator sep; see Line Separator:

f = File.new('t.txt')
f.each_line('li') {|line| p line }
f.close

Output:

"First li"
"ne\nSecond li"
"ne\n\nFourth li"
"ne\nFifth li"
"ne\n"

The two special values for sep are honored:

f = File.new('t.txt')
# Get all into one string.
f.each_line(nil) {|line| p line }
f.close

Output:

"First line\nSecond line\n\nFourth line\nFifth line\n"

f.rewind
# Get paragraphs (up to two line separators).
f.each_line('') {|line| p line }

Output:

"First line\nSecond line\n\n"
"Fourth line\nFifth line\n"

With only integer argument limit given, limits the number of bytes in each line; see Line Limit:

f = File.new('t.txt')
f.each_line(8) {|line| p line }
f.close

Output:

"First li"
"ne\n"
"Second l"
"ine\n"
"\n"
"Fourth l"
"ine\n"
"Fifth li"
"ne\n"

With arguments sep and limit given, combines the two behaviors:

Optional keyword argument chomp specifies whether line separators are to be omitted:

f = File.new('t.txt')
f.each_line(chomp: true) {|line| p line }
f.close

Output:

"First line"
"Second line"
""
"Fourth line"
"Fifth line"

Returns an Enumerator if no block is given.

IO#each is an alias for IO#each_line.

Calls the given block with each byte (0..255) in the stream; returns self. See Byte IO.

f = File.new('t.rus')
a = []
f.each_byte {|b| a << b }
a # => [209, 130, 208, 181, 209, 129, 209, 130]
f.close

Returns an Enumerator if no block is given.

Related: IO#each_char, IO#each_codepoint.

Calls the given block with each codepoint in the stream; returns self:

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

Returns an Enumerator if no block is given.

Related: IO#each_byte, IO#each_char.

With no argument, returns the value of $!, which is the result of the most recent pattern match (see Regexp Global Variables):

/c(.)t/ =~ 'cat'  # => 0
Regexp.last_match # => #<MatchData "cat" 1:"a">
/a/ =~ 'foo'      # => nil
Regexp.last_match # => nil

With non-negative integer argument n, returns the _n_th field in the matchdata, if any, or nil if none:

/c(.)t/ =~ 'cat'     # => 0
Regexp.last_match(0) # => "cat"
Regexp.last_match(1) # => "a"
Regexp.last_match(2) # => nil

With negative integer argument n, counts backwards from the last field:

Regexp.last_match(-1)       # => "a"

With string or symbol argument name, returns the string value for the named capture, if any:

/(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ 'var = val'
Regexp.last_match        # => #<MatchData "var = val" lhs:"var"rhs:"val">
Regexp.last_match(:lhs)  # => "var"
Regexp.last_match('rhs') # => "val"
Regexp.last_match('foo') # Raises IndexError.

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
No documentation available
Search took: 9ms  ·  Total Results: 1079