Class: NtqExcelsior::MultiWorkbookExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/ntq_excelsior/multi_workbook_exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exporters = []) ⇒ MultiWorkbookExporter

Returns a new instance of MultiWorkbookExporter.



8
9
10
# File 'lib/ntq_excelsior/multi_workbook_exporter.rb', line 8

def initialize(exporters = [])
  @exporters = exporters
end

Instance Attribute Details

#exportersObject

Returns the value of attribute exporters.



6
7
8
# File 'lib/ntq_excelsior/multi_workbook_exporter.rb', line 6

def exporters
  @exporters
end

Instance Method Details

#exportObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ntq_excelsior/multi_workbook_exporter.rb', line 12

def export
  exports = exporters
  exports = [exporters] if exporters && !exporters.is_a?(Array)

  package = Axlsx::Package.new
  wb = package.workbook
  wb_styles = wb.styles

  exports.each do |exporter|
    exporter.generate_workbook(wb, wb_styles)
  end

  package
end