Method: Doing::CSVExport.render

Defined in:
lib/doing/plugins/export/csv_export.rb

.render(wwid, items, variables: {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/doing/plugins/export/csv_export.rb', line 20

def self.render(wwid, items, variables: {})
  return if items.nil?

  opt = variables[:options]

  output = [CSV.generate_line(%w[start end title note timer section])]
  items.each do |i|
    note = format_note(i.note)
    end_date = i.end_date
    interval = end_date && opt[:times] ? wwid.get_interval(i, formatted: false) : 0
    output.push(CSV.generate_line([i.date, end_date, i.title, note, interval, i.section]))
  end
  Doing.logger.debug('CSV Export:', "#{items.count} items output to CSV")
  output.join('')
end