Class: ArcFurnace::ExcelSink
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(filename:, fields:, types: nil) ⇒ ExcelSink
constructor
A new instance of ExcelSink.
- #row(hash) ⇒ Object
Methods inherited from Sink
Constructor Details
#initialize(filename:, fields:, types: nil) ⇒ ExcelSink
Returns a new instance of ExcelSink.
8 9 10 11 12 13 14 15 16 |
# File 'lib/arc-furnace/excel_sink.rb', line 8 def initialize(filename: , fields:, types: nil) @filename = filename @fields = fields @package = Axlsx::Package.new @workbook = package.workbook @worksheet = workbook.add_worksheet(name: 'Sheet1') @types = types ? types : [] worksheet.add_row(fields) end |
Instance Method Details
#finalize ⇒ Object
18 19 20 |
# File 'lib/arc-furnace/excel_sink.rb', line 18 def finalize package.serialize(filename) end |
#row(hash) ⇒ Object
22 23 24 |
# File 'lib/arc-furnace/excel_sink.rb', line 22 def row(hash) worksheet.add_row(fields.map { |field_id| hash[field_id] }, types: types) end |