Module: Format
- Included in:
- CSVR::App
- Defined in:
- lib/csvr/format.rb
Class Method Summary collapse
-
.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.
- .row(row) ⇒ Object
- .type(types) ⇒ Object
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 13 |
# File 'lib/csvr/format.rb', line 9 def headers(headers) headers = headers.map { |h| "#{h} TEXT" }.join(",") return headers end |
.row(row) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/csvr/format.rb', line 22 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 |
.type(types) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/csvr/format.rb', line 15 def type(types) #Convert Fixnum to Int, etc end |