End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
CSV::Table.new
new(array_of_rows, headers: nil)
lib/csv/table.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/csv/table.rb, line 31
def initialize(array_of_rows, headers: nil)
@table = array_of_rows
@headers = headers
unless @headers
if @table.empty?
@headers = []
else
@headers = @table.first.headers
end
end
@mode = :col_or_row
end
Constructs a new CSV::Table from array_of_rows, which are expected to be CSV::Row objects. All rows are assumed to have the same headers.
The optional headers parameter can be set to Array of headers. If headers aren’t set, headers are fetched from CSV::Row objects. Otherwise, headers() method will return headers being set in headers argument.
A CSV::Table object supports the following Array methods through delegation:
-
empty?()
-
length()
-
size()