Class: StixSchemaSpy::ComplexType
- Includes:
- HasChildren
- Defined in:
- lib/stix_schema_spy/models/complex_type.rb
Instance Attribute Summary
Attributes inherited from Type
#documentation, #inline, #name, #schema
Class Method Summary collapse
-
.build(xml, schema) ⇒ Object
Build a new complex type by trying to find special classes and either using those or the generic type.
Instance Method Summary collapse
-
#complex? ⇒ Boolean
Returns whether or not this type is a complex type.
-
#enumeration? ⇒ Boolean
Complex types can’t be enumerations?.
-
#initialize(*args) ⇒ ComplexType
constructor
A new instance of ComplexType.
- #load! ⇒ Object
-
#vocab_values ⇒ Object
Returns a list of possible values for that vocabulary.
Methods included from HasChildren
#attributes, #elements, #fields, #find_attribute, #find_element, #own_fields
Methods inherited from Type
#abstract?, #ancestors, #child_types, counter, #doc_path, #example, find, #full_name, #get_extension, #has_example?, #has_own_fields?, inline, #inspect, #own_usages, #parent_type, #prefix, #stix_version, #url, #usages, #use, #use_parent, #vocab?
Constructor Details
#initialize(*args) ⇒ ComplexType
Returns a new instance of ComplexType.
8 9 10 11 12 13 14 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 8 def initialize(*args) @attributes = {} @elements = {} @types = {} @special_fields = [] super end |
Class Method Details
.build(xml, schema) ⇒ Object
Build a new complex type by trying to find special classes and either using those or the generic type
23 24 25 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 23 def self.build(xml, schema) ComplexType.new(xml, schema) end |
Instance Method Details
#complex? ⇒ Boolean
Returns whether or not this type is a complex type
28 29 30 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 28 def complex? true end |
#enumeration? ⇒ Boolean
Complex types can’t be enumerations?
33 34 35 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 33 def enumeration? false end |
#load! ⇒ Object
16 17 18 19 20 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 16 def load! return if @loaded @xml.elements.each {|child| process_field(child) } @loaded = true end |
#vocab_values ⇒ Object
Returns a list of possible values for that vocabulary
40 41 42 43 44 45 46 47 48 |
# File 'lib/stix_schema_spy/models/complex_type.rb', line 40 def vocab_values type = Schema.find(self.schema.prefix, stix_version).find_type(name.gsub("Vocab", "Enum")) if type type.enumeration_values else raise "Unable to find corresponding enumeration for vocabulary" end end |