Class: MyData::Xsd::ComplexType

Inherits:
Object
  • Object
show all
Defined in:
lib/my_data/xsd/complex_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, namespace: nil) ⇒ ComplexType

Returns a new instance of ComplexType.



6
7
8
9
# File 'lib/my_data/xsd/complex_type.rb', line 6

def initialize(doc, namespace: nil)
  @doc = doc
  @namespace = namespace
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



4
5
6
# File 'lib/my_data/xsd/complex_type.rb', line 4

def doc
  @doc
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



4
5
6
# File 'lib/my_data/xsd/complex_type.rb', line 4

def namespace
  @namespace
end

Instance Method Details

#elementsObject



15
16
17
18
19
# File 'lib/my_data/xsd/complex_type.rb', line 15

def elements
  @elements ||= extract_elements(doc).flatten.map do |element|
    MyData::Xsd::Element.new(element)
  end
end

#inspectObject



21
22
23
# File 'lib/my_data/xsd/complex_type.rb', line 21

def inspect
  "ComplexType: { name: #{name.to_json}, elements: #{elements} }"
end

#nameObject



11
12
13
# File 'lib/my_data/xsd/complex_type.rb', line 11

def name
  @name ||= doc.attributes["name"].value.camelize
end