Class: Infoboxer::Navigation::Sections::Section

Inherits:
Tree::Compound show all
Includes:
Container
Defined in:
lib/infoboxer/navigation/sections.rb

Overview

Virtual node, representing logical section of the document. Is not, in fact, in the tree.

See parent module documentation for details.

Instance Attribute Summary collapse

Attributes inherited from Tree::Compound

#children

Attributes inherited from Tree::Node

#params, #parent

Instance Method Summary collapse

Methods included from Container

#intro, #lookup_children, #sections, #subsections

Methods inherited from Tree::Compound

#index_of, #text, #to_tree

Methods inherited from Tree::Node

#==, #children, coder, def_readers, #first?, #index, #next_siblings, #prev_siblings, #siblings, #text, #text_, #to_s, #to_tree

Methods included from Wikipath

#wikipath

Methods included from Node

#in_sections

Methods included from Infoboxer::Navigation::Shortcuts::Node

#bold?, #categories, #external_links, #heading?, #headings, #images, #infobox, #infoboxes, #italic?, #lists, #paragraphs, #tables, #templates, #wikilinks

Methods included from Lookup::Node

#_lookup, #_lookup_children, #_lookup_next_siblings, #_lookup_parents, #_lookup_prev_sibling, #_lookup_prev_siblings, #_lookup_siblings, #_matches?, #lookup, #lookup_children, #lookup_next_siblings, #lookup_parents, #lookup_prev_sibling, #lookup_prev_siblings, #lookup_siblings, #matches?, #parent?

Constructor Details

#initialize(heading, children = ) ⇒ Section

Returns a new instance of Section.



189
190
191
192
193
194
# File 'lib/infoboxer/navigation/sections.rb', line 189

def initialize(heading, children = Tree::Nodes[])
  # no super: we don't wont to rewrite children's parent
  @children = Tree::Nodes[*children]
  @heading = heading
  @params = {level: heading.level, heading: heading.text.strip}
end

Instance Attribute Details

#headingTree::Heading (readonly)

Section's heading.

Returns:



199
200
201
# File 'lib/infoboxer/navigation/sections.rb', line 199

def heading
  @heading
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'lib/infoboxer/navigation/sections.rb', line 208

def empty?
  false
end

#inspectObject



212
213
214
# File 'lib/infoboxer/navigation/sections.rb', line 212

def inspect
  "#<#{descr}: #{children.count} nodes>"
end

#push_children(*nodes) ⇒ Object

no rewriting of parent, again



202
203
204
205
206
# File 'lib/infoboxer/navigation/sections.rb', line 202

def push_children(*nodes)
  nodes.each do |n|
    @children << n
  end
end