Class: RXSD::XSD::SimpleType

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

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

simple type attribute values



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

def id
  @id
end

#listObject

children in schema (only one will be populated)



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

def list
  @list
end

#nameObject

simple type attribute values



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

def name
  @name
end

#parentObject

simpleType parent



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

def parent
  @parent
end

#restrictionObject

children in schema (only one will be populated)



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

def restriction
  @restriction
end

Class Method Details

.from_xml(node) ⇒ Object

node passed in should be a xml node representing the simple type



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rxsd/xsd/simple_type.rb', line 41

def self.from_xml(node)
   simpleType = SimpleType.new
   simpleType.parent = node.parent.related
   node.related = simpleType

   # TODO simpleType attributes: | anyAttr 
   simpleType.id   = node.attrs["id"]
   simpleType.name = node.attrs["name"]

   # parse lists
   simpleType.list = node.child_obj List

   # parse restrictions
   simpleType.restriction = node.child_obj Restriction

   # TODO simpleType children: | unions
   #simpleType.unions = node.child_obj Union

   return simpleType
end

.tag_nameObject

xml tag name



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

def self.tag_name
  "simpleType"
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/simple_type.rb', line 90

def child_attributes
   if !@list.nil?
      return @list.child_attributes
   elsif !@restriction.nil?
      return @restriction.child_attributes
   end
end

#childrenObject

returns array of all children



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

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

#infoObject

return xsd node info



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

def info
  "simple_type id: #{@id} name: #{@name}"
end

#resolve(node_objs) ⇒ Object

resolve hanging references given complete xsd node object array



63
64
# File 'lib/rxsd/xsd/simple_type.rb', line 63

def resolve(node_objs)
end

#to_class_builderObject

convert simple type to class builder



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

def to_class_builder
  unless defined? @class_builder
    @class_builder = nil

    if !@list.nil?
      # dispatch to child list
      @class_builder = @list.to_class_builder

    elsif !@restriction.nil?
      # grab restriction class builder w/ base class and facets
      @class_builder = @restriction.to_class_builder

    #else
    #  @class_builder = ClassBuilder.new

    end
  end

  @class_builder.klass_name = @name.camelize unless @name.nil?
  return @class_builder
end