Class: Infoboxer::Tree::List

Inherits:
Compound show all
Defined in:
lib/infoboxer/tree/list.rb,
lib/infoboxer/tree/list.rb

Overview

"Imaginary" node, grouping ListItems of same level and type.

Base for concrete OrderedList, UnorderedList and DefinitionList.

NB: Nested lists are represented by structures like:

<OrderedList>
 <ListItem>
 <ListItem>
   <Text>
   <UnorderedList>
     <ListItem>
     <ListItem>
...and so on

Direct Known Subclasses

DefinitionList, OrderedList, UnorderedList

Instance Attribute Summary

Attributes inherited from Compound

#children

Attributes inherited from Node

#params, #parent

Instance Method Summary collapse

Methods inherited from Compound

#index_of, #initialize, #to_tree

Methods inherited from Node

#==, #children, coder, def_readers, #index, #initialize, #inspect, #next_siblings, #prev_siblings, #siblings, #text_, #to_s, #to_tree

Methods included from Navigation::Sections::Node

#in_sections

Methods included from Navigation::Shortcuts::Node

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

Methods included from Navigation::Lookup::Node

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

Constructor Details

This class inherits a constructor from Infoboxer::Tree::Compound

Instance Method Details

#list_levelObject



55
56
57
# File 'lib/infoboxer/tree/list.rb', line 55

def list_level
  lookup_parents(List).count
end

#list_text_indentObject



59
60
61
# File 'lib/infoboxer/tree/list.rb', line 59

def list_text_indent
  '  ' * list_level
end

#textObject



63
64
65
66
67
68
69
# File 'lib/infoboxer/tree/list.rb', line 63

def text
  if list_level.zero?
    super.sub(/\n+\Z/, "\n\n")
  else
    super.sub(/\n+\Z/, "\n")
  end
end