Class: CSVPlusPlus::Writer::RubyXLBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Merger
Defined in:
lib/csv_plus_plus/writer/rubyxl_builder.rb

Overview

Build a RubyXL workbook formatted according to the given rows

rubocop:disable Metrics/ClassLength

Constant Summary collapse

RubyXLCell =
::T.type_alias { ::T.all(::RubyXL::Cell, ::RubyXL::CellConvenienceMethods) }
RubyXLValue =
::T.type_alias { ::T.any(::String, ::Numeric, ::Date) }

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Merger

#merge_cell_value

Constructor Details

#initialize(options:, position:, rows:) ⇒ RubyXLBuilder

Returns a new instance of RubyXLBuilder.

Parameters:

  • options (Options::FileOptions)
  • position (Position)

    The current position

  • rows (Array<Row>)

    The rows to write



34
35
36
37
38
39
40
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 34

def initialize(options:, position:, rows:)
  @options = options
  @position = position
  @rows = rows
  @worksheet = ::T.let(open_worksheet, ::RubyXL::Worksheet)
  @reader = ::T.let(::CSVPlusPlus::Reader::RubyXL.new(@options, @worksheet), ::CSVPlusPlus::Reader::RubyXL)
end

Instance Attribute Details

#output_filenamePathname? (readonly)

The filename being written to

Returns:

  • (Pathname, nil)

    the current value of output_filename



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

def output_filename
  @output_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)


46
47
48
49
# File 'lib/csv_plus_plus/writer/rubyxl_builder.rb', line 46

def build_workbook
  build_workbook!
  @worksheet.workbook
end