Class: Giblish::VerbatimTree

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/indexbuilders/verbatimtree.rb

Overview

Generate asciidoc that represents a given pathtree as a verbatim block with indented, clickable entries.

Instance Method Summary collapse

Constructor Details

#initialize(tree, options = {dir_index_base_name: "index"}) ⇒ VerbatimTree

options: dir_index_base_name: String - the basename of the index file residing in each directory



10
11
12
13
14
# File 'lib/giblish/indexbuilders/verbatimtree.rb', line 10

def initialize(tree, options = {dir_index_base_name: "index"})
  @tree = tree
  @nof_missing_titles = 0
  @options = options.dup
end

Instance Method Details

#sourceObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/giblish/indexbuilders/verbatimtree.rb', line 16

def source
  # output tree intro
  tree_string = +<<~DOC_HEADER
    [subs=\"normal\"]
    ----
  DOC_HEADER

  # generate each tree entry string
  @tree.traverse_preorder do |level, node|
    next if level == 0

    tree_string << tree_entry_string(level, node)
  end

  # generate the tree footer
  tree_string << "\n----\n"
end