Class: Asciidoctor::Table::Rows

Inherits:
Object
  • Object
show all
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

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

#bodyObject



14
15
16
# File 'lib/asciidoctor/table.rb', line 14

def body
  @body
end

#footObject



13
14
15
# File 'lib/asciidoctor/table.rb', line 13

def foot
  @foot
end

#headObject



12
13
14
# File 'lib/asciidoctor/table.rb', line 12

def head
  @head
end

Instance Method Details

#by_sectionObject

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.



31
32
33
# File 'lib/asciidoctor/table.rb', line 31

def by_section
  [[:head, @head], [:body, @body], [:foot, @foot]]
end

#to_hObject

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.



41
42
43
# File 'lib/asciidoctor/table.rb', line 41

def to_h
  { head: @head, body: @body, foot: @foot }
end