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 = +"    [subs=\"normal\"]\n    ----\n  DOC_HEADER\n\n  # generate each tree entry string\n  @tree.traverse_preorder do |level, node|\n    next if level == 0\n\n    tree_string << tree_entry_string(level, node)\n  end\n\n  # generate the tree footer\n  tree_string << \"\\n----\\n\"\nend\n"