class OdfCore::Element::AbstractElement
Attributes
attributes[R]
children[R]
Public Class Methods
attributes()
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 10 def attributes self::ATTRIBUTES end
children()
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 6 def children self::CHILDREN end
new()
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 21 def initialize @children = [] @attributes = {} end
xml_element_name()
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 14 def xml_element_name self::XML_ELEMENT_NAME end
Public Instance Methods
<<(element)
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 26 def <<(element) check_child_element!(element) @children << element end
[](attribute_name)
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 38 def [](attribute_name) @attributes[attribute_name] end
[]=(attribute_name, attribute_value)
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 32 def []=(attribute_name, attribute_value) check_attribute!(attribute_name) @attributes[attribute_name] = attribute_value end
Private Instance Methods
check_attribute!(attribute_name)
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 49 def check_attribute!(attribute_name) if !self.class.attributes.include?(attribute_name) raise Error::NotAllowedAttribute.new(self.class.name, attribute_name) end end
check_child_element!(element)
click to toggle source
# File lib/odf_core/element/abstract_element.rb, line 43 def check_child_element!(element) if !self.class.children.include?(element.class.xml_element_name) raise Error::NotAllowedElement.new(self.class.name, element.class) end end