Class: RD::Element

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rd/element.rb

Overview

abstruct class of node of document tree

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeElement

Returns a new instance of Element.



10
11
12
# File 'lib/rd/element.rb', line 10

def initialize
  @parent = nil
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/rd/element.rb', line 8

def parent
  @parent
end

Instance Method Details

#inspectObject



19
20
21
22
# File 'lib/rd/element.rb', line 19

def inspect
  c  = children.collect{|i| indent2(i.inspect)}.join("\n")
  "<#{self.class.name}>" + (c.empty? ? "" : "\n") + c
end

#treeObject

Raises:

  • (RuntimeError)


14
15
16
17
# File 'lib/rd/element.rb', line 14

def tree
  raise RuntimeError, "#{self} doesn't have a parent." unless @parent
  @parent.tree
end