Class: CsvExportService

Inherits:
Object
  • Object
show all
Includes:
DataExportHelper
Defined in:
app/models/rails_data/export_services/csv_export_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DataExportHelper

#convert_parameters, #field_result, #footer_result, #header_result

Constructor Details

#initializeCsvExportService

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

#headersObject (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

#sheetObject (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_csvObject



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