Class: Spreadshoot::Row

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

Overview

A row of a table. The table could be horizontal oriented, or vertical oriented.

Instance Method Summary collapse

Constructor Details

#initialize(table, options = {}) ⇒ Row

Note:

Do not call directly, rows should be created using Table#row or #Worksheet#row methods

Returns a new instance of Row.



504
505
506
507
# File 'lib/spreadshoot.rb', line 504

def initialize table, options = {}
  @table = table
  @options = options
end

Instance Method Details

#cell(value = nil, options = {}) ⇒ Object

Creates a cell within a row.

Parameters:

  • value (Object) (defaults to: nil)

    a value to write to the cell

  • options (Hash) (defaults to: {})

    additional options applied (formatting, etc)

Returns:

  • created Cell instance



515
516
517
518
519
520
521
522
523
524
525
# File 'lib/spreadshoot.rb', line 515

def cell value = nil, options = {}
  cell = Cell.new(@table, value, @options.merge(options))
  @table.worksheet.cells[@table.current_row] ||= {}
  @table.worksheet.cells[@table.current_row][@table.current_col] = cell
  if @table.direction == :vertical
    @table.col_index += 1
  else
    @table.row_index += 1
  end
  cell
end