Class: Coradoc::CoreModel::Table

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/core_model/table.rb

Overview

Represents a table in a document

Tables contain rows of cells and support various formatting options like frame, grid, column widths, and styling.

Examples:

Creating a simple table

table = CoreModel::Table.new(
  title: "Data Table",
  rows: [
    CoreModel::TableRow.new(
      cells: [
        CoreModel::TableCell.new(content: "Header 1", header: true),
        CoreModel::TableCell.new(content: "Header 2", header: true)
      ],
      header: true
    ),
    CoreModel::TableRow.new(
      cells: [
        CoreModel::TableCell.new(content: "Cell 1"),
        CoreModel::TableCell.new(content: "Cell 2")
      ]
    )
  ]
)

Creating a table with column specifications

table = CoreModel::Table.new(
  cols: ["1", "2", "3"],  # relative widths
  col_alignments: ["left", "center", "right"],
  col_styles: [nil, "emphasis", "monospace"],
  rows: [...]
)

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Method Summary

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#colsArray<String>?

Returns column width specifications (e.g., [“1”, “2”, “3”]).

Returns:

  • (Array<String>, nil)

    column width specifications (e.g., [“1”, “2”, “3”])



165
# File 'lib/coradoc/core_model/table.rb', line 165

attribute :cols, :string, collection: true

#frameString?

Note:

Populated by HTML converter only

Returns table frame style (‘all’, ‘topbot’, ‘sides’, ‘none’).

Returns:

  • (String, nil)

    table frame style (‘all’, ‘topbot’, ‘sides’, ‘none’)



152
# File 'lib/coradoc/core_model/table.rb', line 152

attribute :frame, :string

#gridString?

Note:

Not yet wired by any transformer; reserved for future use

Returns table grid style (‘all’, ‘cols’, ‘rows’, ‘none’).

Returns:

  • (String, nil)

    table grid style (‘all’, ‘cols’, ‘rows’, ‘none’)



157
# File 'lib/coradoc/core_model/table.rb', line 157

attribute :grid, :string

#rowsArray<TableRow>

Returns collection of table rows.

Returns:

  • (Array<TableRow>)

    collection of table rows



147
# File 'lib/coradoc/core_model/table.rb', line 147

attribute :rows, TableRow, collection: true

#widthString?

Returns table width (e.g., ‘100%’, ‘500px’).

Returns:

  • (String, nil)

    table width (e.g., ‘100%’, ‘500px’)



161
# File 'lib/coradoc/core_model/table.rb', line 161

attribute :width, :string