Class: Idml::Elements::Cell

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/idml/elements/cell.rb

Overview

<Cell> — a single cell in an IDML Table. Per Cell_Object in reference-docs/schemas/package/Stories/Story.rnc.

Schema note: real IDML has <Cell> and <Row> as siblings inside <Table>, not nested <TableRow><TableCell>. This class is the schema-faithful model. The legacy Idml::Elements::TableCell (which models the non-standard <TableCell> element) is preserved for back-compat with the existing synthetic test fixture — see TODO 84.

The cell's Name attribute encodes its column/row position as "col:row" (e.g., "0:0", "1:2"). Carries text content via inline <ParagraphStyleRange><CharacterStyleRange><Content> children, the same structure as a Story.

Instance Method Summary collapse

Instance Method Details

#col_rowObject

Cell name format is "col:row" (e.g., "0:0", "1:2"). Returns [col, row] integers or nil if Name is malformed.



252
253
254
255
256
257
258
259
# File 'lib/idml/elements/cell.rb', line 252

def col_row
  return nil unless name

  parts = name.split(":")
  return nil unless parts.length == 2

  [parts[0].to_i, parts[1].to_i]
end

#text_contentObject



246
247
248
# File 'lib/idml/elements/cell.rb', line 246

def text_content
  paragraph_style_range.filter_map(&:text_content).join
end