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.



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

#bodyObject



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

def body
  @body
end

#footObject



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

def foot
  @foot
end

#headObject



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

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.



28
29
30
# File 'lib/asciidoctor/table.rb', line 28

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.



38
39
40
# File 'lib/asciidoctor/table.rb', line 38

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