Class: SentimentInsights::Export::CsvExporter
- Inherits:
-
BaseExporter
- Object
- BaseExporter
- SentimentInsights::Export::CsvExporter
- Defined in:
- lib/sentiment_insights/export/csv_exporter.rb
Instance Attribute Summary
Attributes inherited from BaseExporter
#analysis_type, #options, #result
Instance Method Summary collapse
Methods inherited from BaseExporter
Constructor Details
This class inherits a constructor from SentimentInsights::Export::BaseExporter
Instance Method Details
#export(filename = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sentiment_insights/export/csv_exporter.rb', line 6 def export(filename = nil) filename ||= generate_filename("csv") # Apply filters if specified filtered_result = apply_filters(@result) CSV.open(filename, "w", encoding: [:encoding]) do |csv| write_main_data(csv, filtered_result) if [:include_summary] write_empty_row(csv) write_summary_section(csv) end if [:include_segments] write_empty_row(csv) write_segment_section(csv) end end filename end |