Class: RSpecDocumentation::PageTreeElement

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_documentation/page_tree_element.rb

Overview

An element in a page tree, generates a single entry as a list item, linked to the relevant document (or just a text entry if no document exists, i.e. if it is a directory without an index file).

Instance Method Summary collapse

Constructor Details

#initialize(path:, child:, current_path:) ⇒ PageTreeElement

Returns a new instance of PageTreeElement.

Raises:



8
9
10
11
12
13
14
# File 'lib/rspec_documentation/page_tree_element.rb', line 8

def initialize(path:, child:, current_path:)
  @path = path
  @child = child
  @current_path = current_path
  @nodes = []
  raise MissingFileError, "Missing file: #{entry_path.relative_path_from(Util.base_dir)}" unless entry?
end

Instance Method Details

#nodeObject



16
17
18
19
20
21
22
23
# File 'lib/rspec_documentation/page_tree_element.rb', line 16

def node
  return nil if entry_and_directory?

  nodes.push(li_open)
  nodes.push(link)
  nodes.push('</li>')
  nodes
end