Class: RRTF::ListNode

Inherits:
CommandNode show all
Defined in:
lib/rrtf/node/list_node.rb

Overview

This class represents an ordered/unordered list within an RTF document.

Currently list nodes can contain any type of node, but this behaviour will change in future releases. The class overrides the list method to return a ListLevelNode.

Instance Attribute Summary

Attributes inherited from CommandNode

#prefix, #split, #suffix, #wrap

Attributes inherited from ContainerNode

#children

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from CommandNode

#<<, #apply, #footnote, #geometry, #image, #line_break, #link, #paragraph, #table, #to_rtf

Methods inherited from ContainerNode

#[], #each, #first, #last, #size, #store, #to_rtf

Methods inherited from Node

#is_root?, #next_node, #previous_node, #root

Constructor Details

#initialize(parent) ⇒ ListNode

Returns a new instance of ListNode



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rrtf/node/list_node.rb', line 9

def initialize(parent)
  prefix  = "\\"

  suffix  = '\pard'
  suffix << ListLevel::ResetTabs.map {|tw| "\\tx#{tw}"}.join
  suffix << '\ql\qlnatural\pardirnatural\cf0 \\'

  super(parent, prefix, suffix, true, false)

  @template = root.lists.new_template
end

Instance Method Details

#list(kind) ⇒ Object

This method creates a new ListLevelNode of the given kind and stores it in the document tree.

Parameters

kind

The kind of this list level, may be either :bullets or :decimal



26
27
28
# File 'lib/rrtf/node/list_node.rb', line 26

def list(kind)
  self.store ListLevelNode.new(self, @template, kind)
end