class Infoboxer::Tree::ListItem
Represents item of ordered or unordered list.
Public Instance Methods
can_merge?(other)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/list.rb, line 9 def can_merge?(other) other.class == self.class && other.children.first.is_a?(List) end
merge!(other)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/list.rb, line 16 def merge!(other) ochildren = other.children.dup children.last.merge!(ochildren.shift) \ if children.last&.can_merge?(ochildren.first) push_children(*ochildren) end
text()
click to toggle source
# File lib/infoboxer/tree/list.rb, line 23 def text make_marker + if children.last.is_a?(List) children[0..-2].map(&:text).join + "\n" + children.last.text else children.map(&:text).join + "\n" end end
Private Instance Methods
make_marker()
click to toggle source
# File lib/infoboxer/tree/list.rb, line 34 def make_marker parent ? parent.make_marker(self) : '* ' end