class HexaPDF::Document::Layout::CellArgumentCollector

Parent

This helper class is used by Layout#table_box to allow specifying the keyword arguments used when converting cell data to box instances.

Constants

ArgumentInfo

Stores a single keyword argument definition for a number of rows/columns.

Attributes

argument_infos[R]

Returns all stored ArgumentInfo instances.

Public Class Methods

new(number_of_rows, number_of_columns)

Creates a new instance, providing the number of rows and columns of the table.

Public Instance Methods

[]=(rows = 0..-1, cols = 0..-1, args)

Stores the hash args containing styling properties for the cells specified via the given 0-based rows and columns.

Rows and columns can either be single numbers, ranges of numbers or stepped ranges (i.e. Enumerator::ArithmeticSequence instances).

Examples:

# Gray background for all cells
args[] = {cell: {background_color: "gray"}}

# Cell at (2, 3) gets a bigger font size
args[2, 3] = {font_size: 50}

# First column of every row has bold font
args[0..-1, 0] = {font: 'Helvetica bold'}

# Every second row has a blue background
args[(0..-1).step(2)] = {cell: {background_color: "blue"}}
retrieve_arguments_for(row, col)

Retrieves the merged keyword arguments for the cell in row and col.

Earlier defined arguments are overridden by later ones, except for the :cell key which is merged.