Class: CsvExportService
- Inherits:
-
Object
- Object
- CsvExportService
- Includes:
- DataExportHelper
- Defined in:
- app/models/rails_data/export_services/csv_export_service.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
Instance Method Summary collapse
-
#initialize ⇒ CsvExportService
constructor
A new instance of CsvExportService.
- #to_csv ⇒ Object
Methods included from DataExportHelper
#convert_parameters, #field_result, #footer_result, #header_result
Constructor Details
#initialize ⇒ CsvExportService
Returns a new instance of CsvExportService.
7 8 9 10 11 12 |
# File 'app/models/rails_data/export_services/csv_export_service.rb', line 7 def initialize headers = config_table end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'app/models/rails_data/export_services/csv_export_service.rb', line 5 def headers @headers end |
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet.
5 6 7 |
# File 'app/models/rails_data/export_services/csv_export_service.rb', line 5 def sheet @sheet end |
Instance Method Details
#to_csv ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/models/rails_data/export_services/csv_export_service.rb', line 15 def to_csv csv = '' csv << headers.to_csv self.table_items.each do |table_item| csv << table_item.fields.to_csv end csv end |