Class: OpenStax::Utilities::Blocks::TableRowBlock
- Defined in:
- lib/openstax/utilities/blocks/table_row_block.rb
Instance Attribute Summary collapse
-
#cell_blocks ⇒ Object
readonly
Returns the value of attribute cell_blocks.
-
#section_heading ⇒ Object
readonly
Returns the value of attribute section_heading.
Attributes inherited from BlockBase
Instance Method Summary collapse
- #add_cell(value) ⇒ Object
- #add_cell_block(&block) ⇒ Object
-
#initialize(template, block) ⇒ TableRowBlock
constructor
A new instance of TableRowBlock.
- #section_heading? ⇒ Boolean
- #set_section_heading(heading, colspan) ⇒ Object
Methods inherited from BlockBase
Constructor Details
#initialize(template, block) ⇒ TableRowBlock
Returns a new instance of TableRowBlock.
10 11 12 13 14 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 10 def initialize(template, block) super(template, "table_row", block) self.cell_blocks = [] self.section_heading = false end |
Instance Attribute Details
#cell_blocks ⇒ Object
Returns the value of attribute cell_blocks.
7 8 9 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 7 def cell_blocks @cell_blocks end |
#section_heading ⇒ Object
Returns the value of attribute section_heading.
8 9 10 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 8 def section_heading @section_heading end |
Instance Method Details
#add_cell(value) ⇒ Object
21 22 23 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 21 def add_cell(value) self.cell_blocks << TableCellBlock.from_value(h, value) end |
#add_cell_block(&block) ⇒ Object
16 17 18 19 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 16 def add_cell_block(&block) self.cell_blocks << h.table_cell_block(&block) self end |
#section_heading? ⇒ Boolean
25 26 27 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 25 def section_heading? section_heading end |
#set_section_heading(heading, colspan) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/openstax/utilities/blocks/table_row_block.rb', line 29 def set_section_heading(heading, colspan) raise "TableRowBlock cannot be a table section heading if it contains cells" \ if cell_blocks.any? raise "TableRowBlock section heading cannot be changed once initialized" \ if section_heading? tcb = TableCellBlock.from_value(h, heading) tcb.set_section_heading(colspan) self.cell_blocks << tcb self.section_heading = true self end |