Results for: "Dir.chdir"

The required_ruby_version constraint for this specification

A fallback is included because when generated, some marshalled specs have it set to nil.

The required_rubygems_version constraint for this specification

A fallback is included because the original version of the specification API didn’t include that field, so some marshalled specs in the index have it set to nil.

The required_ruby_version constraint for this specification

The required_rubygems_version constraint for this specification

No documentation available

Like Enumerable#chunk, but chains operation to be lazy-evaluated.

Iterates over the elements of the first enumerable by calling the “each” method on it with the given arguments, then proceeds to the following enumerables in sequence until all of the enumerables are exhausted.

If no block is given, returns an enumerator.

Iterates over the elements of the first enumerable by calling the “each_entry” method on it with the given arguments, then proceeds to the following enumerables in sequence until all of the enumerables are exhausted.

If no block is given, returns an enumerator. Otherwise, returns self.

No documentation available

Iterates for each entry in the /etc/passwd file if a block is given.

If no block is given, returns the Enumerator.

The code block is passed an Passwd struct.

See Etc.getpwent above for details.

Example:

require 'etc'

Etc::Passwd.each {|u|
  puts u.name + " = " + u.gecos
}

Etc::Passwd.collect {|u| u.gecos}
Etc::Passwd.collect {|u| u.gecos}

Iterates for each entry in the /etc/group file if a block is given.

If no block is given, returns the Enumerator.

The code block is passed a Group struct.

Example:

require 'etc'

Etc::Group.each {|g|
  puts g.name + ": " + g.mem.join(', ')
}

Etc::Group.collect {|g| g.name}
Etc::Group.select {|g| !g.mem.empty?}
No documentation available

Retrieves the section and its pairs for the current configuration.

config.each do |section, key, value|
  # ...
end
No documentation available
No documentation available
No documentation available
No documentation available

See Zlib::GzipReader documentation for a description.

See Zlib::GzipReader documentation for a description.

Returns true if the file is a character device, false if it isn’t or if the operating system doesn’t support this feature.

File.stat("/dev/tty").chardev?   #=> true

Iterates over the buffer, yielding each value of buffer_type starting from offset.

If count is given, only count values will be yielded.

IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value|
  puts "#{offset}: #{value}"
end
# 2: 108
# 3: 108
No documentation available

Returns the field value as specified by header.


With the single argument header, returns the field value for that header (first found):

source = "Name,Name,Name\nFoo,Bar,Baz\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.fetch('Name') # => "Foo"

Raises exception KeyError if the header does not exist.


With arguments header and default given, returns the field value for the header (first found) if the header exists, otherwise returns default:

source = "Name,Name,Name\nFoo,Bar,Baz\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.fetch('Name', '') # => "Foo"
row.fetch(:nosuch, '') # => ""

With argument header and a block given, returns the field value for the header (first found) if the header exists; otherwise calls the block and returns its return value:

source = "Name,Name,Name\nFoo,Bar,Baz\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.fetch('Name') {|header| fail 'Cannot happen' } # => "Foo"
row.fetch(:nosuch) {|header| "Header '#{header} not found'" } # => "Header 'nosuch not found'"

Calls the block with each header-value pair; returns self:

source = "Name,Name,Name\nFoo,Bar,Baz\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.each {|header, value| p [header, value] }

Output:

["Name", "Foo"]
["Name", "Bar"]
["Name", "Baz"]

If no block is given, returns a new Enumerator:

row.each # => #<Enumerator: #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz">:each>

Calls the block with each row or column; returns self.

When the access mode is :row or :col_or_row, calls the block with each CSV::Row object:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_row! # => #<CSV::Table mode:row row_count:4>
table.each {|row| p row }

Output:

#<CSV::Row "Name":"foo" "Value":"0">
#<CSV::Row "Name":"bar" "Value":"1">
#<CSV::Row "Name":"baz" "Value":"2">

When the access mode is :col, calls the block with each column as a 2-element array containing the header and an Array of column fields:

table.by_col! # => #<CSV::Table mode:col row_count:4>
table.each {|column_data| p column_data }

Output:

["Name", ["foo", "bar", "baz"]]
["Value", ["0", "1", "2"]]

Returns a new Enumerator if no block is given:

table.each # => #<Enumerator: #<CSV::Table mode:col row_count:4>:each>
Search took: 6ms  ·  Total Results: 1391