Method: CSV::Table#push

Defined in:
lib/csv/table.rb

#push(*rows) ⇒ Object

:call-seq:

table.push(*rows_or_arrays) -> self

A shortcut for appending multiple rows. Equivalent to:

rows.each {|row| self << row }

Each argument may be either a CSV::Row object or an Array:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
rows = [
  CSV::Row.new(table.headers, ['bat', 3]),
  ['bam', 4]
]
table.push(*rows)
table[3..4] # => [#<CSV::Row "Name":"bat" "Value":3>, #<CSV::Row "Name":"bam" "Value":4>]


788
789
790
791
792
# File 'lib/csv/table.rb', line 788

def push(*rows)
  rows.each { |row| self << row }

  self # for chaining
end