Class: RTF::ListLevelNode
- Inherits:
-
CommandNode
- Object
- Node
- ContainerNode
- CommandNode
- RTF::ListLevelNode
- Defined in:
- lib/rtf/node.rb
Overview
This class represents a list level, and carries out indenting information and the bullet or number that is prepended to each ListTextNode.
The class overrides the list method to implement nesting, and provides the item method to add a new list item, the ListTextNode.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the kind of this level, either :bullets or :decimal.
Attributes inherited from CommandNode
#prefix, #split, #suffix, #wrap
Attributes inherited from ContainerNode
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(parent, template, kind, level = 1) ⇒ ListLevelNode
constructor
A new instance of ListLevelNode.
-
#item {|node| ... } ⇒ Object
Creates a new
ListTextNodeand yields it to the calling block. -
#level ⇒ Object
Returns the indenting level of this list, from 1 to 9.
-
#list(kind = @kind) {|node| ... } ⇒ Object
Creates a new
ListLevelNodeto implement nested lists.
Methods inherited from CommandNode
#<<, #apply, #background, #bold, #colour, #font, #footnote, #foreground, #image, #italic, #line_break, #link, #paragraph, #strike, #subscript, #superscript, #table, #to_rtf, #underline
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, template, kind, level = 1) ⇒ ListLevelNode
638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/rtf/node.rb', line 638 def initialize(parent, template, kind, level=1) @template = template @kind = kind @level = template.level_for(level, kind) prefix = '\pard' prefix << @level.tabs.map {|tw| "\\tx#{tw}"}.join prefix << "\\li#{@level.indent}\\fi-#{@level.indent}" prefix << "\\ql\\qlnatural\\pardirnatural\n" prefix << "\\ls#{@template.id}\\ilvl#{@level.level-1}\\cf0" super(parent, prefix, nil, true, false) end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the kind of this level, either :bullets or :decimal
653 654 655 |
# File 'lib/rtf/node.rb', line 653 def kind @kind end |
Instance Method Details
#item {|node| ... } ⇒ Object
Creates a new ListTextNode and yields it to the calling block
661 662 663 664 665 |
# File 'lib/rtf/node.rb', line 661 def item node = ListTextNode.new(self, @level) yield node self.store(node) end |
#level ⇒ Object
Returns the indenting level of this list, from 1 to 9
656 657 658 |
# File 'lib/rtf/node.rb', line 656 def level @level.level end |
#list(kind = @kind) {|node| ... } ⇒ Object
Creates a new ListLevelNode to implement nested lists
668 669 670 671 672 |
# File 'lib/rtf/node.rb', line 668 def list(kind=@kind) node = ListLevelNode.new(self, @template, kind, @level.level+1) yield node self.store(node) end |