Class: CSVExporter
- Inherits:
-
Object
- Object
- CSVExporter
- Defined in:
- lib/search_logger/csv_exporter.rb
Instance Method Summary collapse
Instance Method Details
#export(data, options) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/search_logger/csv_exporter.rb', line 4 def export(data, ) @data = data @to = [:to] save_to_file unless @data.empty? end |
#save_to_file ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/search_logger/csv_exporter.rb', line 11 def save_to_file CSV.open(@to, "wb") do |csv| csv << %w{keyword position url title description} @data.each do |d| csv << [d[:searched_keyword], d[:position], d[:url], d[:title], d[:description]] end end end |