class Xommelier::Xml::Element
Attributes
options[R]
Public Class Methods
new(contents = {}, options = {})
click to toggle source
# File lib/xommelier/xml/element.rb, line 26 def initialize(contents = {}, options = {}) self.options = options @elements = {} @attributes = {} @text = nil @errors = [] set_default_values case contents when Hash contents.each do |name, value| send("#{name}=", value) end else send(:text=, contents) end end
Public Instance Methods
inspect()
click to toggle source
# File lib/xommelier/xml/element.rb, line 53 def inspect %(#<#{self.class.name}:0x#{object_id.to_s(16)} #{inspect_contents}>) end
options=(options = {})
click to toggle source
Calls superclass method
Xommelier::Xml::Element::Structure#options=
# File lib/xommelier/xml/element.rb, line 46 def options=(options = {}) super @options = options @options[:validate] = !!xmlns.try(:schema) unless @options[:validate] @options.delete(:type) end
Private Instance Methods
inspect_attributes()
click to toggle source
# File lib/xommelier/xml/element.rb, line 65 def inspect_attributes "@attributes={#{@attributes.map { |name, value| "#{name}: #{value.inspect}" }.join(', ')}}" if @attributes.any? end
inspect_contents()
click to toggle source
# File lib/xommelier/xml/element.rb, line 61 def inspect_contents [inspect_attributes, inspect_elements, inspect_text].compact.join(' ') end
inspect_elements()
click to toggle source
# File lib/xommelier/xml/element.rb, line 69 def inspect_elements @elements.map { |name, value| "@#{name}=#{value.inspect}" }.join(' ').to_s if @elements.any? end
inspect_text()
click to toggle source
# File lib/xommelier/xml/element.rb, line 73 def inspect_text text.inspect if text? end