Class: Forms::CsvExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/forms/csv_exporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CsvExporter

Returns a new instance of CsvExporter.



4
5
6
# File 'lib/forms/csv_exporter.rb', line 4

def initialize(form)
  @form = form
end

Instance Method Details

#to_csvObject



8
9
10
11
12
13
14
15
16
# File 'lib/forms/csv_exporter.rb', line 8

def to_csv
  CSV.generate do |csv|
    csv << headers
    
    @form.submissions.each do |submission|
      csv << values(submission)
    end
  end
end