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.
13 14 15 16 17 |
# File 'lib/asciidoctor/table.rb', line 13 def initialize head = [], foot = [], body = [] @head = head @foot = foot @body = body end |
Instance Attribute Details
#body ⇒ Object
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 def body @body end |
#foot ⇒ Object
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 def foot @foot end |
#head ⇒ Object
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 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).
28 29 30 |
# File 'lib/asciidoctor/table.rb', line 28 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).
38 39 40 |
# File 'lib/asciidoctor/table.rb', line 38 def to_h { head: @head, body: @body, foot: @foot } end |