Class: Asciidoctor::Table::Rows
- Inherits:
-
Object
- Object
- Asciidoctor::Table::Rows
- Defined in:
- lib/asciidoctor/table.rb
Overview
Public: A data object that encapsulates the collection of rows (head, foot, body) for a table
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#foot ⇒ Object
Returns the value of attribute foot.
-
#head ⇒ Object
Returns the value of attribute head.
Instance Method Summary collapse
-
#by_section ⇒ Object
Public: Retrieve the rows grouped by section as a nested Array.
-
#initialize(head = [], foot = [], body = []) ⇒ Rows
constructor
A new instance of Rows.
-
#to_h ⇒ Object
Public: 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
Returns the value of attribute body.
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 def body @body end |
#foot ⇒ Object
Returns the value of attribute foot.
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 def foot @foot end |
#head ⇒ Object
Returns the value of attribute head.
11 12 13 |
# File 'lib/asciidoctor/table.rb', line 11 def head @head end |
Instance Method Details
#by_section ⇒ Object
Public: 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).
Returns a 2-dimentional Array of rows grouped by section.
28 29 30 |
# File 'lib/asciidoctor/table.rb', line 28 def by_section [[:head, @head], [:body, @body], [:foot, @foot]] end |
#to_h ⇒ Object
Public: 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).
Returns a Hash of rows grouped by section.
38 39 40 |
# File 'lib/asciidoctor/table.rb', line 38 def to_h { head: @head, body: @body, foot: @foot } end |