Class: Latexmath::XML::Element
- Inherits:
-
Object
- Object
- Latexmath::XML::Element
- Defined in:
- lib/latexmath/xml/element.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
Instance Method Summary collapse
-
#initialize(parent, tag, attributes = {}) ⇒ Element
constructor
A new instance of Element.
- #set_attribute(key, value) ⇒ Object
- #tag=(tag) ⇒ Object
- #text=(value) ⇒ Object
Constructor Details
#initialize(parent, tag, attributes = {}) ⇒ Element
Returns a new instance of Element.
4 5 6 7 8 9 10 11 |
# File 'lib/latexmath/xml/element.rb', line 4 def initialize(parent, tag, attributes = {}) @element = Ox::Element.new(tag) attributes.each do |key, value| @element[key] = value end @parent = parent.is_a?(Latexmath::XML::Element) ? parent.element : parent @parent << @element end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
3 4 5 |
# File 'lib/latexmath/xml/element.rb', line 3 def element @element end |
Instance Method Details
#set_attribute(key, value) ⇒ Object
21 22 23 |
# File 'lib/latexmath/xml/element.rb', line 21 def set_attribute(key, value) @element[key] = value end |
#tag=(tag) ⇒ Object
13 14 15 |
# File 'lib/latexmath/xml/element.rb', line 13 def tag=(tag) @element.value = tag end |
#text=(value) ⇒ Object
17 18 19 |
# File 'lib/latexmath/xml/element.rb', line 17 def text=(value) @element << Ox::Raw.new(value) end |