class StixSchemaSpy::SimpleType

Public Class Methods

build(xml, schema) click to toggle source
# File lib/stix_schema_spy/models/simple_type.rb, line 6
def self.build(xml, schema)
  self.new(xml, schema)
end

Public Instance Methods

complex?() click to toggle source

Not a complex type

# File lib/stix_schema_spy/models/simple_type.rb, line 31
def complex?
  false
end
elements() click to toggle source
# File lib/stix_schema_spy/models/simple_type.rb, line 43
def elements
  []
end
enumeration?() click to toggle source

Returns whether or not this simple type is an enumeration

# File lib/stix_schema_spy/models/simple_type.rb, line 11
def enumeration?
  @is_enumeration ||= @xml.xpath('./xs:restriction/xs:enumeration', {'xs' => 'http://www.w3.org/2001/XMLSchema'}).length > 0
end
enumeration_values() click to toggle source

Returns the list of values for this enumeration

# File lib/stix_schema_spy/models/simple_type.rb, line 16
def enumeration_values
  enumeration = @xml.xpath('./xs:restriction/xs:enumeration', {'xs' => 'http://www.w3.org/2001/XMLSchema'})
  if enumeration.length > 0
    return enumeration.map {|elem| [elem.attributes['value'].value, elem.xpath('./xs:annotation/xs:documentation', {'xs' => 'http://www.w3.org/2001/XMLSchema'}).text]}
  else
    raise "Not an enumeration"
  end    
end
fields() click to toggle source
# File lib/stix_schema_spy/models/simple_type.rb, line 35
def fields
  []
end
has_example?() click to toggle source

A shortcut to checking whether there's an example because simple types never have examples

# File lib/stix_schema_spy/models/simple_type.rb, line 26
def has_example?
  false
end
own_fields() click to toggle source
# File lib/stix_schema_spy/models/simple_type.rb, line 39
def own_fields
  []
end