class GovukTechDocs::TableOfContents::HeadingTree

Attributes

children[RW]
heading[RW]
parent[RW]

Public Class Methods

new(parent: nil, heading: nil, children: []) click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading_tree.rb, line 6
def initialize(parent: nil, heading: nil, children: [])
  @parent = parent
  @heading = heading
  @children = children
end

Public Instance Methods

==(other) click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading_tree.rb, line 20
def ==(other)
  heading == other.heading &&
    children.length == other.children.length &&
    children.map.with_index { |child, index| child == other.children[index] }.all?
end
depth() click to toggle source
# File lib/govuk_tech_docs/table_of_contents/heading_tree.rb, line 12
def depth
  if parent
    parent.depth + 1
  else
    1
  end
end