Class: RXSD::XSD::List

Inherits:
Object
  • Object
show all
Defined in:
lib/rxsd/xsd/list.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

list attributes



14
15
16
# File 'lib/rxsd/xsd/list.rb', line 14

def id
  @id
end

#itemTypeObject

list attributes



14
15
16
# File 'lib/rxsd/xsd/list.rb', line 14

def itemType
  @itemType
end

#parentObject

list parent



20
21
22
# File 'lib/rxsd/xsd/list.rb', line 20

def parent
  @parent
end

#simple_typeObject

list children



17
18
19
# File 'lib/rxsd/xsd/list.rb', line 17

def simple_type
  @simple_type
end

Class Method Details

.from_xml(node) ⇒ Object

node passed in should be a xml node representing the list



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rxsd/xsd/list.rb', line 40

def self.from_xml(node)
   list = List.new
   list.parent = node.parent.related
   node.related = list

   # TODO list attributes: | anyAttributes
   list.id       = node.attrs["id"]


   if node.children.find { |c| c.name == SimpleType.tag_name }.nil?
      list.itemType = node.attrs["itemType"]
   else
      list.simple_type   = node.child_obj SimpleType
   end

   return list
end

.tag_nameObject

xml tag name



23
24
25
# File 'lib/rxsd/xsd/list.rb', line 23

def self.tag_name
  "list"
end

Instance Method Details

#child_attributesObject

return all child_attributes associated w/ simple type



90
91
92
93
94
95
96
# File 'lib/rxsd/xsd/list.rb', line 90

def child_attributes
  if !@itemType.nil? && @itemType.class == SimpleType
     return @itemType.child_attributes
  elsif !@simple_type.nil?
     return @simple_type.child_attributes
  end
end

#childrenObject

returns array of all children



33
34
35
36
37
# File 'lib/rxsd/xsd/list.rb', line 33

def children
  c = []
  c.push @simple_type unless @simple_type.nil?
  return c
end

#infoObject

return xsd node info



28
29
30
# File 'lib/rxsd/xsd/list.rb', line 28

def info
  "list id: #{@id}"
end

#resolve(node_objs) ⇒ Object

resolve hanging references given complete xsd node object array



59
60
61
62
63
64
# File 'lib/rxsd/xsd/list.rb', line 59

def resolve(node_objs)
  unless @itemType.nil?
    builtin = Parser.parse_builtin_type @itemType
    @itemType = !builtin.nil? ? builtin : node_objs[SimpleType].find { |no| no.name == @itemType }
  end
end

#to_class_builderObject

convert list to class builder



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rxsd/xsd/list.rb', line 67

def to_class_builder
   unless defined? @class_builder
     # convert list to builder producing array of classes specified by item type or simple type
     @class_builder = ClassBuilder.new :klass => Array

     if !@itemType.nil?
       if @itemType.class == SimpleType
         @class_builder.associated_builder = @itemType.to_class_builder
       else
         @class_builder.associated_builder = ClassBuilder.new :klass => @itemType
       end

     elsif !@simple_type.nil?
       @class_builder.associated_builder = @simple_type.to_class_builder

     end
   end

   return @class_builder
end