AshReports.Layout.IR.Cell (ash_reports v0.1.0)
Intermediate Representation for a cell in a layout.
The CellIR represents a single cell with its calculated position, span information, properties, and content.
Position
Position is represented as a {x, y} tuple where:
xis the column index (0-indexed)yis the row index (0-indexed)
Span
Span is represented as a {colspan, rowspan} tuple where:
colspanis the number of columns the cell spans (default: 1)rowspanis the number of rows the cell spans (default: 1)
Examples
# Cell at position (0, 0) with default span
cell = AshReports.Layout.IR.Cell.new(
position: {0, 0},
content: [label_ir]
)
# Cell with colspan of 2
cell = AshReports.Layout.IR.Cell.new(
position: {1, 0},
span: {2, 1},
content: [field_ir]
)
Summary
Functions
Adds content to the cell.
Returns the colspan of the cell.
Gets a property from the cell.
Creates a new CellIR struct with the given options.
Returns all positions occupied by this cell (including spans).
Sets a property on the cell.
Returns the rowspan of the cell.
Returns the x (column) coordinate of the cell.
Returns the y (row) coordinate of the cell.
Types
@type position() :: {non_neg_integer(), non_neg_integer()}
@type span() :: {pos_integer(), pos_integer()}
@type t() :: %AshReports.Layout.IR.Cell{ content: [AshReports.Layout.IR.Content.t()], position: position(), properties: map(), span: span() }
Functions
@spec add_content(t(), AshReports.Layout.IR.Content.t()) :: t()
Adds content to the cell.
@spec colspan(t()) :: pos_integer()
Returns the colspan of the cell.
Gets a property from the cell.
Creates a new CellIR struct with the given options.
Options
:position-{x, y}tuple for cell position (default:{0, 0}):span-{colspan, rowspan}tuple (default:{1, 1}):properties- Map of cell properties (align, inset, fill, etc.):content- List of ContentIR items
Examples
iex> AshReports.Layout.IR.Cell.new(position: {1, 2}, span: {2, 1})
%AshReports.Layout.IR.Cell{position: {1, 2}, span: {2, 1}, ...}
Returns all positions occupied by this cell (including spans).
Examples
iex> cell = AshReports.Layout.IR.Cell.new(position: {1, 0}, span: {2, 2})
iex> AshReports.Layout.IR.Cell.occupied_positions(cell)
[{1, 0}, {2, 0}, {1, 1}, {2, 1}]
Sets a property on the cell.
@spec rowspan(t()) :: pos_integer()
Returns the rowspan of the cell.
@spec x(t()) :: non_neg_integer()
Returns the x (column) coordinate of the cell.
@spec y(t()) :: non_neg_integer()
Returns the y (row) coordinate of the cell.