method
generate_row
v1_8_7_330 -
Show latest stable
-
0 notes -
Class: CSV
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
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.