Class: Gollum::DescendantTree::TreeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gollum/descendant_tree/tree_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(wiki, name) ⇒ TreeBuilder

Returns a new instance of TreeBuilder.



5
6
7
8
9
# File 'lib/gollum/descendant_tree/tree_builder.rb', line 5

def initialize (wiki, name)
  @wiki = wiki
  @name = name
  @current_nest_index = 0
end

Instance Method Details

#treeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gollum/descendant_tree/tree_builder.rb', line 11

def tree
  current_page_name = get_current_page_name
  page_descendants = []
  previous_page = ''
  @wiki.pages.each do |page|
    if (page.url_path.include?(current_page_name))
      page_descendants << {
        title: page.title,
        url_path: page.url_path,
        nest_index: get_current_index(page, previous_page)
      }
      previous_page = page
    end
    
  end
  page_descendants
end