Module: Format

Included in:
CSVR::App
Defined in:
lib/csvr/format.rb

Class Method Summary collapse

Class Method Details

.headers(headers) ⇒ Object

TODO: Interpret data types from the second line of a csv file TODO: Headers should reflect the data types of their rows



9
10
11
12
# File 'lib/csvr/format.rb', line 9

def headers(headers)
	headers = headers.map { |h| "#{h} TEXT"}
	return headers.join(",")
end

.row(row) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/csvr/format.rb', line 14

def row(row)

	if row.is_a? Hash
		values = row.values.map { |r| "'#{r}'"}.join(",")
		keys = row.keys.join(",")
	end
	return "(#{keys}) VALUES(#{values})"
end