module Infoboxer::Navigation::Sections::Node
Part of {Sections} navigation, allowing each node to know exact list of sections it contained in.
See also {Sections parent module} documentation.
Public Instance Methods
in_sections()
click to toggle source
List of sections current node contained in (bottom-to-top: smallest section first).
@return {Tree::Nodes<Section>}
# File lib/infoboxer/navigation/sections.rb, line 139 def in_sections return parent.in_sections unless parent.is_a?(Tree::Document) return @in_sections if @in_sections heading = if is_a?(Tree::Heading) lookup_prev_sibling(Tree::Heading, level: level - 1) else lookup_prev_sibling(Tree::Heading) end unless heading @in_sections = Tree::Nodes[] return @in_sections end body = heading.next_siblings .take_while { |n| !n.is_a?(Tree::Heading) || n.level > heading.level } section = Section.new(heading, body) @in_sections = Tree::Nodes[section, *heading.in_sections] end