Class: Lutaml::Xsd::SchemaClassificationInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/schema_classifier.rb

Overview

Value object for schema classification info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema:, location:, category:) ⇒ SchemaClassificationInfo

Returns a new instance of SchemaClassificationInfo.



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/lutaml/xsd/schema_classifier.rb', line 158

def initialize(schema:, location:, category:)
  @location = location
  @category = category
  @namespace = schema.target_namespace
  @elements_count = schema.element.size
  @complex_types_count = schema.complex_type.size
  @simple_types_count = schema.simple_type.size
  @types_count = @complex_types_count + @simple_types_count
  @imports_count = schema.import.size
  @includes_count = schema.include.size
  @external_refs = extract_external_references(schema)
  @resolution_status = determine_resolution_status
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def category
  @category
end

#elements_countObject (readonly)

Returns the value of attribute elements_count.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def elements_count
  @elements_count
end

#external_refsObject (readonly)

Returns the value of attribute external_refs.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def external_refs
  @external_refs
end

#locationObject (readonly)

Returns the value of attribute location.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def location
  @location
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def namespace
  @namespace
end

#resolution_statusObject (readonly)

Returns the value of attribute resolution_status.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def resolution_status
  @resolution_status
end

#types_countObject (readonly)

Returns the value of attribute types_count.



155
156
157
# File 'lib/lutaml/xsd/schema_classifier.rb', line 155

def types_count
  @types_count
end

Instance Method Details

#fully_resolved?Boolean

Check if schema is fully resolved

Returns:

  • (Boolean)

    True if all references are resolved



174
175
176
# File 'lib/lutaml/xsd/schema_classifier.rb', line 174

def fully_resolved?
  @resolution_status == :fully_resolved
end

#partially_resolved?Boolean

Check if schema is partially resolved

Returns:

  • (Boolean)

    True if some references are unresolved



180
181
182
# File 'lib/lutaml/xsd/schema_classifier.rb', line 180

def partially_resolved?
  @resolution_status == :partially_resolved
end

#to_hHash

Convert to hash representation

Returns:

  • (Hash)

    Hash representation of the classification info



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/lutaml/xsd/schema_classifier.rb', line 186

def to_h
  {
    location: @location,
    filename: File.basename(@location),
    category: @category,
    namespace: @namespace || "(no namespace)",
    elements_count: @elements_count,
    types_count: @types_count,
    complex_types_count: @complex_types_count,
    simple_types_count: @simple_types_count,
    imports_count: @imports_count,
    includes_count: @includes_count,
    resolution_status: @resolution_status,
    external_refs_count: @external_refs.size,
  }
end