Class: GovukTechDocs::TableOfContents::HeadingTreeRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb

Constant Summary collapse

DEFAULT_MAX_LEVEL =
Float::INFINITY
DEFAULT_INDENTATION =
"".freeze
INDENTATION_INCREMENT =
"  ".freeze

Instance Method Summary collapse

Constructor Details

#initialize(heading_tree, max_level: nil) ⇒ HeadingTreeRenderer

Returns a new instance of HeadingTreeRenderer.



8
9
10
11
# File 'lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb', line 8

def initialize(heading_tree, max_level: nil)
  @heading_tree = heading_tree
  @max_level = max_level || DEFAULT_MAX_LEVEL
end

Instance Method Details

#htmlObject



13
14
15
# File 'lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb', line 13

def html
  render_tree(@heading_tree, level: 0)
end