Class: RD::Tree

### Home Classes Methods

### In Files

- lib/rd/tree.rb

### Parent

Object

### Methods

- ::new
- ::new_from_rdo
- ::new_with_document_struct
- ::tmp_dir
- ::version
- #accept
- #check_valid
- #each
- #each_element
- #make_root
- #parse
- #root=
- #set_root
- #tree

### Included Modules

- Enumerable

### Files

- post-install

### Class/Module Index

Quicksearch

- RD
- RD::AutoLabel
- RD::BlockElement
- RD::Code
- RD::ComplexListItem
- RD::DescList
- RD::DescListItem
- RD::DescListItem::Term
- RD::DocumentElement
- RD::DocumentStructure
- RD::Element
- RD::ElementRelationship
- RD::Emphasis
- RD::EnumList
- RD::EnumListItem
- RD::Filter
- RD::Filter::FileInclude
- RD::Footnote
- RD::Headline
- RD::Include
- RD::Index
- RD::InlineElement
- RD::InlineIncludable
- RD::ItemList
- RD::ItemListItem
- RD::Keyboard
- RD::LabelComposable
- RD::LabeledElement
- RD::List
- RD::ListItem
- RD::ListItemComposable
- RD::MethodList
- RD::MethodListItem
- RD::MethodListItem::Term
- RD::MethodParse
- RD::NonterminalElement
- RD::NonterminalInline
- RD::OutputFormatVisitor
- RD::ParserUtility
- RD::Part
- RD::RBLFile
- RD::RBLSuite
- RD::RD2HTMLExtVisitor
- RD::RD2HTMLExtVisitor::EnableBr
- RD::RD2HTMLExtVisitor::HeadElement
- RD::RD2HTMLExtVisitor::HeadLineTitle
- RD::RD2HTMLExtVisitor::HeadlineSecno
- RD::RD2HTMLExtVisitor::NativeInline
- RD::RD2HTMLExtVisitor::RefExtension
- RD::RD2HTMLVisitor
- RD::RD2MANVisitor
- RD::RD2RDOVisitor
- RD::RD2RMIVisitor
- RD::RDElement
- RD::RDInlineParser
- RD::RDParser
- RD::RDTree
- RD::RDVisitor
- RD::Reference
- RD::Reference::Label
- RD::Reference::RDLabel
- RD::Reference::TemporaryLabel
- RD::Reference::URL
- RD::ReferenceResolver
- RD::SearchFile
- RD::StringElement
- RD::TerminalElement
- RD::TerminalInline
- RD::TextBlock
- RD::Tree
- RD::Var
- RD::Verb
- RD::Verbatim
- RD::Version
- RD::Visitor
- Array

No matching classes.

# RD::Tree

document tree

### Constants

SYSTEM_NAME
SYSTEM_VERSION
TMP_DIR
VERSION

### Attributes

document_struct[R]
filter[R]
filters[R]
include_path[RW]
include_path=[RW]
include_paths[RW]
root[R]
tmp_dir[RW]

### Public Class Methods

new(document_struct, src_str = nil, include_paths = []) click to toggle source

    # File lib/rd/tree.rb, line 39
    def initialize(document_struct, src_str = nil, include_paths = [])
      @src = src_str
      @document_struct = document_struct
      @include_paths = include_paths
      @filters = Hash.new()
      @tmp_dir = TMP_DIR
      @root = nil
    end

new_from_rdo(*rdos) click to toggle source

    # File lib/rd/tree.rb, line 92
    def Tree.new_from_rdo(*rdos) # rdos: IOs
      tree = Tree.new("", [], nil)
      tree_content = []
      rdos.each do |i|
        subtree = Marshal.load(i)
        tree_content.concat(subtree.root.blocks)
      end
      tree.root = DocumentElement.new(tree_content)
      tree
    end

new_with_document_struct(document_struct, include_paths = []) click to toggle source

    # File lib/rd/tree.rb, line 35
    def Tree.new_with_document_struct(document_struct, include_paths = [])
      Tree.new(document_struct, nil, include_paths)
    end

tmp_dir() click to toggle source

    # File lib/rd/tree.rb, line 22
    def Tree.tmp_dir
      TMP_DIR
    end

version() click to toggle source

    # File lib/rd/tree.rb, line 16
    def Tree.version
      VERSION
    end

### Public Instance Methods

accept(visitor) click to toggle source

    # File lib/rd/tree.rb, line 78
    def accept(visitor)
      @root.accept(visitor)
    end

check_valid() click to toggle source

    # File lib/rd/tree.rb, line 69
    def check_valid
      each_element do |i|
        raise RuntimeError,
          "mismatched document structure, #{i.parent} <-/- #{i}." unless
          @document_struct.is_valid?(i.parent, i)
      end
      true
    end

each(&block) click to toggle source
Alias for: each_element
each_element(&block) click to toggle source

    # File lib/rd/tree.rb, line 82
    def each_element(&block)
      return nil unless @root
      @root.each(&block)
    end

Also aliased as: each
make_root(&block) click to toggle source

    # File lib/rd/tree.rb, line 62
    def make_root(&block)
      child = DocumentElement.new
      set_root(child)
      child.build(&block) if block_given?
      child
    end

parse() click to toggle source

    # File lib/rd/tree.rb, line 48
    def parse
      parser = RDParser.new
      src = @src.respond_to?(:to_a) ? @src.to_a : @src.split(/^/)
      set_root(parser.parse(src, self))
    end

root=(element) click to toggle source
Alias for: set_root
set_root(element) click to toggle source

    # File lib/rd/tree.rb, line 54
    def set_root(element)
      raise ArgumentError, "#{element.class} can't be root." unless
        @document_struct.is_valid?(self, element)
      @root = element
      element.parent = self
    end

Also aliased as: root=
tree() click to toggle source

    # File lib/rd/tree.rb, line 88
    def tree
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.