Class: Lutaml::Xsd::TypeHierarchyAnalyzer

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

Overview

Analyzes type inheritance hierarchies Single responsibility: build and analyze type hierarchy trees Separates analysis logic from presentation (visualization formats)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ TypeHierarchyAnalyzer

Returns a new instance of TypeHierarchyAnalyzer.



11
12
13
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 11

def initialize(repository)
  @repository = repository
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



9
10
11
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 9

def repository
  @repository
end

Instance Method Details

#analyze(qualified_name, depth: 10) ⇒ Hash?

Analyze complete hierarchy for a type

Parameters:

  • qualified_name (String)

    The qualified type name (e.g., “gml:AbstractFeatureType”)

  • depth (Integer) (defaults to: 10)

    Maximum depth to traverse (default: 10)

Returns:

  • (Hash, nil)

    Hierarchy analysis result or nil if type not found



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 19

def analyze(qualified_name, depth: 10)
  type_result = @repository.find_type(qualified_name)
  return nil unless type_result.resolved?

  root_node = build_tree(qualified_name, depth)

  {
    root: qualified_name,
    namespace: type_result.namespace,
    local_name: type_result.local_name,
    type_category: determine_type_category(type_result.definition),
    ancestors: find_ancestors(type_result.definition, depth),
    descendants: find_descendants(qualified_name, depth),
    tree: root_node.to_h,
    formats: {
      mermaid: to_mermaid(root_node),
      text: to_text_tree(root_node),
    },
  }
end