Class: Uniword::Wordprocessingml::Table
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Uniword::Wordprocessingml::Table
- Defined in:
- lib/uniword/wordprocessingml/table.rb
Overview
Table structure
Generated from OOXML schema: wordprocessingml.yml Element: <w:tbl>
Instance Method Summary collapse
-
#accept(visitor) ⇒ void
Accept a visitor (Visitor pattern).
-
#column_count ⇒ Integer
Get column count.
-
#columns ⇒ Array<Array<TableCell>>
Get columns (transposed view of table cells).
-
#empty? ⇒ Boolean
Check if table is empty (no rows).
-
#row_count ⇒ Integer
Get row count.
Instance Method Details
#accept(visitor) ⇒ void
This method returns an undefined value.
Accept a visitor (Visitor pattern)
68 69 70 |
# File 'lib/uniword/wordprocessingml/table.rb', line 68 def accept(visitor) visitor.visit_table(self) end |
#column_count ⇒ Integer
Get column count
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 |
#columns ⇒ Array<Array<TableCell>>
Get columns (transposed view of table 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)
48 49 50 |
# File 'lib/uniword/wordprocessingml/table.rb', line 48 def empty? rows.empty? end |
#row_count ⇒ Integer
Get row count
32 33 34 |
# File 'lib/uniword/wordprocessingml/table.rb', line 32 def row_count rows.count end |