class Infoboxer::Tree::List
“Imaginary” node, grouping {ListItem}s 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 “`
Constants
- ITEMS
@private
- LISTS
@private
Public Class Methods
construct(marker, nodes)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/list.rb, line 132 def self.construct(marker, nodes) m = marker.shift klass = LISTS[m] or fail("Something went wrong: undefined list marker type #{m}") item_klass = ITEMS[m] if marker.empty? klass.new(item_klass.new(nodes)) else klass.new(item_klass.new(construct(marker, nodes))) end end
Public Instance Methods
list_level()
click to toggle source
# File lib/infoboxer/tree/list.rb, line 56 def list_level lookup_parents(List).count end
list_text_indent()
click to toggle source
# File lib/infoboxer/tree/list.rb, line 60 def list_text_indent ' ' * list_level end
merge!(other)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/list.rb, line 119 def merge!(other) ochildren = other.children.dup if children.last && ochildren.first && children.last.can_merge?(ochildren.first) children.last.merge!(ochildren.shift) end push_children(*ochildren) end
text()
click to toggle source
Calls superclass method
Infoboxer::Tree::Compound#text
# File lib/infoboxer/tree/list.rb, line 64 def text if list_level.zero? super.sub(/\n+\Z/, "\n\n") else super.sub(/\n+\Z/, "\n") end end