Class: RD::Element
Overview
abstruct class of node of document tree
Direct Known Subclasses
BlockElement, DescListItem::Term, DocumentElement, InlineElement, MethodListItem::Term
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #tree ⇒ Object
Constructor Details
#initialize ⇒ Element
Returns a new instance of Element.
10 11 12 |
# File 'lib/rd/element.rb', line 10 def initialize @parent = nil end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
8 9 10 |
# File 'lib/rd/element.rb', line 8 def parent @parent end |
Instance Method Details
#inspect ⇒ Object
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 |
#tree ⇒ Object
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 |