Class: CSVPlusPlus::Writer::RubyXLBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_plus_plus/writer/rubyxl_builder.rb

Overview

Build a RubyXL workbook formatted according to the given rows

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_filename:, rows:, sheet_name:) ⇒ RubyXLBuilder

Returns a new instance of RubyXLBuilder.

Parameters:

  • input_filename (String)

    The file to write to

  • rows (Array<Row>)

    The rows to write

  • sheet_name (String)

    The name of the sheet within the workbook to write to



17
18
19
20
21
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 17

def initialize(input_filename:, rows:, sheet_name:)
  @rows = rows
  @input_filename = input_filename
  @sheet_name = sheet_name
end

Instance Attribute Details

#input_filenameString (readonly)

The filename being written to

Returns:

  • (String)

    the current value of input_filename



11
12
13
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 11

def input_filename
  @input_filename
end

#rowsArray<Row> (readonly)

The rows being written

Returns:

  • (Array<Row>)

    the current value of rows



11
12
13
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 11

def rows
  @rows
end

Instance Method Details

#build_workbookRubyXL::Workbook

Build a RubyXL::Workbook with the given @rows in sheet_name

Returns:

  • (RubyXL::Workbook)


26
27
28
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 26

def build_workbook
  open_workbook.tap { build_workbook! }
end