field

field( header )field( header, offset )field( index ) Instance Public methods This method will return the field value by header or index. If a field is not found, nil is returned. When provided, offset ensures that a header match occurrs on or later than the offset index. You can use this to find duplicate headers, without resorting to hard-coding exact indices. []

fetch

fetch( header )fetch( header ) { |row| ... }fetch( header, default ) Instance Public methods This method will fetch the field value by header. It has the same behavior as Hash#fetch: if there is a field with the given header, its value is returned. Otherwise, if a block is given, it is yielded the header and its result is returned; if a default is given as the second argument, it is returned; otherwise a KeyError is raised.

each

each(&block) Instance Public methods Yields each pair of the row as header and field tuples (much like iterating over a Hash). Support for Enumerable. This method returns the row for chaining.

delete_if

delete_if(&block) Instance Public methods The provided block is passed a header and field for each pair in the row and expected to return true or false, depending on whether the pair should be deleted. This method returns the row for chaining.

delete

delete( header )delete( header, offset )delete( index ) Instance Public methods Used to remove a pair from the row by header or index. The pair is located as described in #field. The deleted pair is returned, or nil if a pair could not be found.

[]=

[]=( header, value )[]=( header, offset, value )[]=( index, value ) Instance Public methods Looks up the field by the semantics described in #field and assigns the value. Assigning past the end of the row with an index will set all pairs between to [nil, nil]. Assigning to an unused header appends the new pair.

[]

[](header_or_index, minimum_index = 0) Instance Public methods Alias for: field

==

==(other) Instance Public methods Returns true if this row contains the same headers and fields in the same order as other.

<<

Instance Public methods If a two-element Array is provided, it is assumed to be a header and field and the pair is appended. A Hash works the same way with the key being the header and the value being the field. Anything else is assumed to be a lone field which is appended with a nil header. This method returns the row for chaining.

new

new(headers, fields, header_row = false) Class Public methods Construct a new CSV::Row from headers and fields, which are expected to be Arrays. If one Array is shorter than the other, it will be padded with nil objects. The optional header_row parameter can be set to true to indicate, via #header_row? and #field_row?, that this is a header row. Otherwise, the row is assumes to be a field row. A CSV::Row object supports the following Array methods through delegation: empty?()