Class: Xommelier::Xml::Element

Inherits:
Object
  • Object
show all
Includes:
Namespace, Serialization, Structure
Defined in:
lib/xommelier/xml.rb,
lib/xommelier/xml/element.rb,
lib/xommelier/xml/element/namespace.rb,
lib/xommelier/xml/element/structure.rb,
lib/xommelier/xml/element/serialization.rb,
lib/xommelier/xml/element/structure/property.rb

Defined Under Namespace

Modules: Namespace, Serialization, Structure

Constant Summary

Constants included from Serialization

Serialization::SAVE_OPTIONS, Serialization::SERIALIZATION_OPTIONS

Instance Attribute Summary collapse

Attributes included from Namespace

#schema_validation_errors

Instance Method Summary collapse

Methods included from Serialization

#<=>, #==, #=~, #from_xml, #to_hash, #to_nokogiri, #to_s, #to_xml

Methods included from Namespace

#valid?

Constructor Details

#initialize(contents = {}, options = {}) ⇒ Element

Returns a new instance of Element.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



24
25
26
# File 'lib/xommelier/xml/element.rb', line 24

def options
  @options
end

Instance Method Details

#inspectObject



53
54
55
# File 'lib/xommelier/xml/element.rb', line 53

def inspect
  %(#<#{self.class.name}:0x#{object_id.to_s(16)} #{inspect_contents}>)
end