module Xommelier::Xml::Element::Structure
Protected Instance Methods
attribute_options(name)
click to toggle source
@return [Xommelier::Xml::Element::Structure::Attribute]
# File lib/xommelier/xml/element/structure.rb, line 240 def attribute_options(name) self.class.attributes[name.to_sym] end
element_name(value = nil)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 203 def element_name(value = nil) @element_name = value if value @element_name ||= self.class.element_name end
element_options(name)
click to toggle source
@return [Xommelier::Xml::Element::Structure::Element]
# File lib/xommelier/xml/element/structure.rb, line 209 def element_options(name) self.class.elements[name.to_sym] end
options=(options = {})
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 199 def options=(options = {}) element_name(options.delete(:element_name)) if options.key?(:element_name) end
read_attribute(name)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 244 def read_attribute(name) @attributes[name.to_sym] end
read_element(name, index = nil)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 213 def read_element(name, index = nil) index ? @elements[name.to_sym][index] : @elements[name.to_sym] end
read_text()
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 262 def read_text @text end
remove_attribute(name)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 254 def remove_attribute(name) @attributes.delete(name.to_sym) end
remove_element(name)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 235 def remove_element(name) @elements.delete(name.to_sym) end
remove_text()
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 270 def remove_text @text = nil end
set_default_values()
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 193 def set_default_values self.class.attributes.merge(self.class.elements).each do |name, property| send("#{name}=", property.default) if property.default? end end
text?()
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 258 def text? respond_to?(:text) end
write_attribute(name, value)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 248 def write_attribute(name, value) type = attribute_options(name).type value = type.from_xommelier(value) unless value.is_a?(type) @attributes[name.to_sym] = value if value end
write_element(name, value, index = nil)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 217 def write_element(name, value, index = nil) element = element_options(name) type = element.type unless value.is_a?(type) value = if element.complex_type? && !value.is_a?(Nokogiri::XML::Node) type.new(value) else type.from_xommelier(value) end end if index @elements[element.name] ||= [] @elements[element.name][index] = value else @elements[element.name] = value end end
write_text(text)
click to toggle source
# File lib/xommelier/xml/element/structure.rb, line 266 def write_text(text) @text = text end