class Rubyxls::Builders::CellBuilder

Attributes

cells[R]

Public Class Methods

new(**opts) click to toggle source
# File lib/rubyxls/builders/cell_builder.rb, line 7
def initialize(**opts)
  @model_data_rows = opts.fetch(:model_data_rows)
  @start_row = opts.fetch(:start_row, 1)
  @start_column = opts.fetch(:start_column, "A")
  @cells = []
  build_cells!
end

Private Instance Methods

assign_row_column!() click to toggle source
# File lib/rubyxls/builders/cell_builder.rb, line 22
def assign_row_column!
  @model_data_rows.each_with_index do |data_row, table_row_index|
    data_row.each_with_index do |data_cell, table_column_index|
      data_cell[:row] = @start_row + table_row_index
      data_cell[:column] = retrieve_cell_column_letter(@start_column, table_column_index)
    end
  end
end
build_cells!() click to toggle source
# File lib/rubyxls/builders/cell_builder.rb, line 17
def build_cells!
  assign_row_column!
  @cells = @model_data_rows.flatten
end
retrieve_cell_column_letter(start_column, table_column_index) click to toggle source
# File lib/rubyxls/builders/cell_builder.rb, line 31
def retrieve_cell_column_letter(start_column, table_column_index)
   cell_column = start_column.clone
   table_column_index.times { cell_column.next! }
   cell_column
end