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?}
Retrieves the section and its pairs for the current configuration.
config.each do |section, key, value| # ... end
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 keys and objects in a weakly referenced object
Iterates over the buffer, yielding each value
of data_type
starting from offset
.
If count
is given, only count
values will be yielded.
Example:
IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value| puts "#{offset}: #{value}" end # 2: 108 # 3: 108
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>
Matches addr
against this entry.
Matches addr
against each ACLEntry
in this list.
Sends a PATCH request to the path
and gets a response, as an HTTPResponse
object.
Sends a PROPPATCH request to the path
and gets a response, as an HTTPResponse
object.
Searches key
in id
list. The result is returned or yielded if a block is given. If it isn’t found, nil is returned.
Completion
for hash key.