Class: Uniword::Wordprocessingml::Table

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/wordprocessingml/table.rb

Overview

Table structure

Generated from OOXML schema: wordprocessingml.yml Element: <w:tbl>

Instance Method Summary collapse

Instance Method Details

#accept(visitor) ⇒ void

This method returns an undefined value.

Accept a visitor (Visitor pattern)

Parameters:

  • visitor (BaseVisitor)

    The visitor to accept



68
69
70
# File 'lib/uniword/wordprocessingml/table.rb', line 68

def accept(visitor)
  visitor.visit_table(self)
end

#column_countInteger

Get column count

Returns:

  • (Integer)

    Maximum number of columns across all rows



39
40
41
42
43
# File 'lib/uniword/wordprocessingml/table.rb', line 39

def column_count
  return 0 if rows.empty?

  rows.map { |r| r.cells&.count || 0 }.max || 0
end

#columnsArray<Array<TableCell>>

Get columns (transposed view of table cells)

Returns:

  • (Array<Array<TableCell>>)

    Array of column arrays, each containing cells



55
56
57
58
59
60
61
62
# File 'lib/uniword/wordprocessingml/table.rb', line 55

def columns
  return [] if rows.empty?

  max_cols = rows.map { |r| r.cells&.count || 0 }.max || 0
  (0...max_cols).map do |col_idx|
    rows.filter_map { |r| r.cells&.[](col_idx) }
  end
end

#empty?Boolean

Check if table is empty (no rows)

Returns:

  • (Boolean)

    true if table has no rows



48
49
50
# File 'lib/uniword/wordprocessingml/table.rb', line 48

def empty?
  rows.empty?
end

#row_countInteger

Get row count

Returns:

  • (Integer)

    Number of rows in table



32
33
34
# File 'lib/uniword/wordprocessingml/table.rb', line 32

def row_count
  rows.count
end