Class: Uniword::Builder::TableCellBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- Uniword::Builder::TableCellBuilder
- Includes:
- HasBorders, HasShading
- Defined in:
- lib/uniword/builder/table_cell_builder.rb
Overview
Builds and configures TableCell objects.
Instance Attribute Summary
Attributes inherited from BaseBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#<<(element) ⇒ self
Append content to the cell.
-
#column_span(count) ⇒ self
Set column span.
-
#row_span(count) ⇒ self
Set row span.
- #vertical_align(value) ⇒ Object
-
#width(value, rule: nil) ⇒ self
Set cell width.
Methods included from HasShading
Methods included from HasBorders
Methods inherited from BaseBuilder
#build, from_model, #initialize
Constructor Details
This class inherits a constructor from Uniword::Builder::BaseBuilder
Class Method Details
.default_model_class ⇒ Object
16 17 18 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 16 def self.default_model_class Wordprocessingml::TableCell end |
Instance Method Details
#<<(element) ⇒ self
Append content to the cell. Routes by type:
-
String -> creates a Paragraph with a Run
-
Paragraph -> appends to paragraphs
-
Table -> appends to nested tables
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 27 def <<(element) case element when String para = Wordprocessingml::Paragraph.new para.runs << Wordprocessingml::Run.new(text: element) @model.paragraphs << para when Wordprocessingml::Paragraph @model.paragraphs << element when Wordprocessingml::Table @model.tables << element when ParagraphBuilder @model.paragraphs << element.build else raise ArgumentError, "Cannot add #{element.class} to table cell" end self end |
#column_span(count) ⇒ self
Set column span
68 69 70 71 72 73 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 68 def column_span(count) ensure_properties @model.properties.grid_span = Wordprocessingml::ValInt.new(value: count) self end |
#row_span(count) ⇒ self
Set row span
79 80 81 82 83 84 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 79 def row_span(count) ensure_properties @model.properties.v_merge = Wordprocessingml::ValInt.new(value: count) self end |
#vertical_align(value) ⇒ Object
58 59 60 61 62 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 58 def vertical_align(value) ensure_properties @model.properties.vertical_align = Properties::CellVerticalAlign.new(value: value.to_s) self end |
#width(value, rule: nil) ⇒ self
Set cell width
50 51 52 53 54 55 56 |
# File 'lib/uniword/builder/table_cell_builder.rb', line 50 def width(value, rule: nil) ensure_properties @model.properties.width ||= Properties::CellWidth.new @model.properties.width.value = value @model.properties.width.rule = rule if rule self end |