Class: XSD::SimpleType
- Inherits:
-
BaseObject
- Object
- BaseObject
- XSD::SimpleType
- Includes:
- Named
- Defined in:
- lib/xsd/objects/simple_type.rb
Overview
The simpleType element defines a simple type and specifies the constraints and information about the values of attributes or text-only elements. Parent elements: attribute, element, list, restriction, schema, union www.w3schools.com/xml/el_simpletype.asp
Constant Summary
Constants inherited from BaseObject
BaseObject::NO_ATTRIBUTES_CONTAINER, BaseObject::NO_ELEMENTS_CONTAINER, BaseObject::XML_SCHEMA
Instance Attribute Summary collapse
-
#list ⇒ Object
Nested list.
-
#name ⇒ Object
Specifies a name for the element.
-
#restriction ⇒ Object
Nested restriction.
-
#union ⇒ Object
Nested union.
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#data_type ⇒ Object
Get base data type.
-
#linked? ⇒ Boolean
Determine if this is a linked type.
Methods included from Named
Methods inherited from BaseObject
#[], #collect_attributes, #collect_elements, #documentation, #documentation_for, #get_prefix, #initialize, #inspect, #map_child, #map_children, #namespaces, #node, #node_to_object, #nodes, #object_by_name, #parent, #reader, #schema, #schemas_for_namespace, #strip_prefix
Constructor Details
This class inherits a constructor from XSD::BaseObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XSD::BaseObject
Instance Attribute Details
#list ⇒ Object
Nested list
30 |
# File 'lib/xsd/objects/simple_type.rb', line 30 child :list, :list |
#name ⇒ Object
Specifies a name for the element. This attribute is required if the simpleType element is a child of the schema element, otherwise it is not allowed
15 |
# File 'lib/xsd/objects/simple_type.rb', line 15 property :name, :string |
#restriction ⇒ Object
Nested restriction
20 |
# File 'lib/xsd/objects/simple_type.rb', line 20 child :restriction, :restriction |
#union ⇒ Object
Nested union
25 |
# File 'lib/xsd/objects/simple_type.rb', line 25 child :union, :union |
Instance Method Details
#data_type ⇒ Object
Get base data type
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/xsd/objects/simple_type.rb', line 40 def data_type if restriction if restriction.base restriction.base_simple_type&.data_type || strip_prefix(restriction.base) else restriction.simple_type&.data_type end elsif union types = union.types.map { |type| type.is_a?(String) ? strip_prefix(type) : type.data_type }.uniq types.size == 1 ? types.first : types else # list is always a sting 'string' end end |
#linked? ⇒ Boolean
Determine if this is a linked type
34 35 36 |
# File 'lib/xsd/objects/simple_type.rb', line 34 def linked? !name.nil? end |