Module: DocTemplate::Objects::TocHelpers

Extended by:
ActiveSupport::Concern
Included in:
ActivityMetadata, AgendaMetadata, SectionsMetadata
Defined in:
lib/doc_template/objects/toc_helpers.rb

Instance Method Summary collapse

Instance Method Details

#find_by_anchor(anchor) ⇒ Object

Raises:



24
25
26
27
28
29
# File 'lib/doc_template/objects/toc_helpers.rb', line 24

def find_by_anchor(anchor)
  l1 = children.find { |c| c.anchor == anchor }
  raise DocumentError, "Anchor #{anchor} not found at metadata" if l1.blank?

  l1
end

#level1_by_title(title) ⇒ Object

Raises:



8
9
10
11
12
13
14
# File 'lib/doc_template/objects/toc_helpers.rb', line 8

def level1_by_title(title)
  l1 = children.find { |c| !c.handled && c.title.parameterize == title }
  raise DocumentError, "Level1 header #{title} not found at metadata" unless l1.present?

  l1.handled = true
  l1
end

#level2_by_title(title) ⇒ Object

Raises:



16
17
18
19
20
21
22
# File 'lib/doc_template/objects/toc_helpers.rb', line 16

def level2_by_title(title)
  children.each do |c|
    l2 = c.children.find { |c1| c1.title.parameterize == title }
    return l2 if l2.present?
  end
  raise DocumentError, "Level2 header #{title} not found at metadata"
end