Class: Kwaff::Element
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#tag ⇒ Object
Returns the value of attribute tag.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(translator, level = 0) ⇒ Object
-
#initialize(tag, children = [], attrs = OrderedHash.new) ⇒ Element
constructor
A new instance of Element.
- #text ⇒ Object
- #text=(str, flag_escape = true) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(tag, children = [], attrs = OrderedHash.new) ⇒ Element
Returns a new instance of Element.
38 39 40 41 42 |
# File 'lib/kwaff/node.rb', line 38 def initialize(tag, children=[], attrs=OrderedHash.new) @tag = tag @children = children @attrs = attrs ## Hash or OrderedHash end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
43 44 45 |
# File 'lib/kwaff/node.rb', line 43 def attrs @attrs end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
43 44 45 |
# File 'lib/kwaff/node.rb', line 43 def children @children end |
#tag ⇒ Object
Returns the value of attribute tag.
44 45 46 |
# File 'lib/kwaff/node.rb', line 44 def tag @tag end |
Instance Method Details
#accept(translator, level = 0) ⇒ Object
35 36 37 |
# File 'lib/kwaff/node.rb', line 35 def accept(translator, level=0) return translator.translate_element(self, level) end |
#text ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/kwaff/node.rb', line 46 def text if @children.length > 0 && @children[0].is_a?(Text) text = children[0] return text.str end return nil end |