Module: RD::NonterminalElement

### Home Classes Methods

### In Files

- lib/rd/element.rb

### Methods

- ::new
- #add_child
- #add_child_under_document_struct
- #add_children
- #add_children_under_document_struct
- #add_children_without_document_struct
- #build
- #children
- #each
- #each_child
- #each_element
- #make_child
- #push_to_children
- #under_temporary_document_structure

### 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::NonterminalElement

element which have children.

### Attributes

temporary_document_structure[RW]

### Public Class Methods

new(*arg) click to toggle source

    # File lib/rd/element.rb, line 39
    def initialize(*arg)
      @temporary_document_structure = nil
      super
    end

### Public Instance Methods

add_child(child) click to toggle source

    # File lib/rd/element.rb, line 62
    def add_child(child)
      add_child_under_document_struct(child, tree.document_struct)
    end

add_child_under_document_struct(child, document_struct) click to toggle source

    # File lib/rd/element.rb, line 66
    def add_child_under_document_struct(child, document_struct)
      if document_struct.is_valid?(self, child)
        push_to_children(child)
      else
        raise ArgumentError,
          "mismatched document structure, #{self} <-/- #{child}."
      end
      return self
    end

add_children(children) click to toggle source

    # File lib/rd/element.rb, line 76
    def add_children(children)
      add_children_under_document_struct(children, tree.document_struct)
    end

add_children_under_document_struct(children, document_struct) click to toggle source

    # File lib/rd/element.rb, line 80
    def add_children_under_document_struct(children, document_struct)
      children.each do |i|
        add_child_under_document_struct(i, document_struct)
      end
      return self
    end

add_children_without_document_struct(new_children) click to toggle source

    # File lib/rd/element.rb, line 87
    def add_children_without_document_struct(new_children)
      new_children.each do |i|
        push_to_children(i)
      end
      return self
    end

build(document_struct = tree.document_struct, &block) click to toggle source

    # File lib/rd/element.rb, line 101
    def build(document_struct = tree.document_struct, &block)
      under_temporary_document_structure(document_struct) do
        self.instance_eval(&block)
      end
      self
    end

children() click to toggle source

    # File lib/rd/element.rb, line 44
    def children
      raise NotImplimentedError, "need #{self}#children."
    end

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

    # File lib/rd/element.rb, line 48
    def each_child
      children.each do |i|
        yield(i)
      end
    end

each_element(&block) click to toggle source

    # File lib/rd/element.rb, line 54
    def each_element(&block)
      yield(self)
      children.each do |i|
        i.each_element(&block)
      end
    end

Also aliased as: each
make_child(child_class, *args_of_new, &block) click to toggle source

    # File lib/rd/element.rb, line 108
    def make_child(child_class, *args_of_new, &block)
      child = child_class.new(*args_of_new)
      if self.temporary_document_structure
        self.add_child_under_document_struct(child,
                                             self.temporary_document_structure)
        child.build(self.temporary_document_structure, &block) if block_given?
      else
        self.add_child(child)
        child.build(&block) if block_given?
      end
      child
    end

Also aliased as: new
push_to_children(child) click to toggle source

    # File lib/rd/element.rb, line 94
    def push_to_children(child)
      children.push(child)
      child.parent = self
    end

under_temporary_document_structure(document_struct) click to toggle source

NonterminalElement#new, not NonterminalElement.new

    # File lib/rd/element.rb, line 124
    def under_temporary_document_structure(document_struct)
      begin
        self.temporary_document_structure = document_struct
        yield
      ensure
        self.temporary_document_structure = nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.