Class: Asciidoctor::Table::Rows
- Inherits:
-
Object
- Object
- Asciidoctor::Table::Rows
- Defined in:
- lib/asciidoctor/table.rb
Overview
A data object that encapsulates the collection of rows (head, foot, body) for a table
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#by_section ⇒ Object
Retrieve the rows grouped by section as a nested Array.
-
#initialize(head = [], foot = [], body = []) ⇒ Rows
constructor
A new instance of Rows.
-
#to_h ⇒ Object
Retrieve the rows as a Hash.
Constructor Details
#initialize(head = [], foot = [], body = []) ⇒ Rows
Returns a new instance of Rows.
16 17 18 19 20 |
# File 'lib/asciidoctor/table.rb', line 16 def initialize head = [], foot = [], body = [] @head = head @foot = foot @body = body end |
Instance Attribute Details
#body ⇒ Object
14 15 16 |
# File 'lib/asciidoctor/table.rb', line 14 def body @body end |
#foot ⇒ Object
13 14 15 |
# File 'lib/asciidoctor/table.rb', line 13 def foot @foot end |
#head ⇒ Object
12 13 14 |
# File 'lib/asciidoctor/table.rb', line 12 def head @head end |
Instance Method Details
#by_section ⇒ Object
Retrieve the rows grouped by section as a nested Array.
Creates a 2-dimensional array of two element entries. The first element is the section name as a symbol. The second element is the Array of rows in that section. The entries are in document order (head, foot, body).
31 32 33 |
# File 'lib/asciidoctor/table.rb', line 31 def by_section [[:head, @head], [:body, @body], [:foot, @foot]] end |
#to_h ⇒ Object
Retrieve the rows as a Hash.
The keys are the names of the section groups and the values are the Array of rows in that section. The keys are in document order (head, foot, body).
41 42 43 |
# File 'lib/asciidoctor/table.rb', line 41 def to_h { head: @head, body: @body, foot: @foot } end |