Flowdock
method

generate_row

Importance_2
Ruby latest stable (v2_5_5) - 0 notes - Class: CSV

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v1_8_7_330) is shown here.

generate_row(src, cells, out_dev, fs = nil, rs = nil) public

Convert a line from cells data to string. Consider using CSV.generate_line instead. To generate multi-row CSV string, see EXAMPLE below.

EXAMPLE

row1 = ['a', 'b']
row2 = ['c', 'd']
row3 = ['e', 'f']
src = [row1, row2, row3]
buf = ''
src.each do |row|
  parsed_cells = CSV.generate_row(row, 2, buf)
  puts "Created #{ parsed_cells } cells."
end
p buf

ARGS

src: an Array of String to be converted to CSV string.  Must respond to
  'size' and '[](idx)'.  src[idx] must return String.
cells: num of cells in a line.
out_dev: buffer for generated CSV string.  Must respond to '<<(string)'.
col_sep: Column separator.  ?, by default.  If you want to separate
  fields with semicolon, give ?; here.
row_sep: Row separator.  nil by default.  nil means "\r\n or \n".  If you
  want to separate records with \r, give ?\r here.

RETURNS

parsed_cells: num of converted cells.
Show source
Register or log in to add new notes.