End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
CSV.generate_lines
# File tmp/rubies/ruby-3.1.3/lib/csv.rb, line 1500
def generate_lines(rows, **options)
self.generate(**options) do |csv|
rows.each do |row|
csv << row
end
end
end
Returns the String created by generating CSV from using the specified options.
Argument rows must be an Array of row. Row is Array of String or CSV::Row.
Special options:
-
Option
:row_sepdefaults to"\n"on Ruby 3.0 or later and$INPUT_RECORD_SEPARATOR($/) otherwise.:Example$INPUT_RECORD_SEPARATOR # => "\n"
-
This method accepts an additional option,
:encoding, which sets the baseEncodingfor the output. This method will try to guess yourEncodingfrom the first non-nilfield inrow, if possible, but you may need to use this parameter as a backup plan.
For other options, see Options for Generating.
Returns the String generated from an
CSV.generate_lines(['foo', '0'], ['bar', '1'], ['baz', '2']) # => "foo,0\nbar,1\nbaz.2\n"
Raises an exception
# Raises NoMethodError (undefined method `find' for :foo:Symbol) CSV.generate_lines(:foo)