Class: Lutaml::Xsd::TypeHierarchyNode
- Inherits:
-
Object
- Object
- Lutaml::Xsd::TypeHierarchyNode
- Defined in:
- lib/lutaml/xsd/type_hierarchy_analyzer.rb
Overview
Value object representing a node in type hierarchy Immutable once created, with ancestors and descendants
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#descendants ⇒ Object
readonly
Returns the value of attribute descendants.
-
#qualified_name ⇒ Object
readonly
Returns the value of attribute qualified_name.
Instance Method Summary collapse
-
#add_ancestor(node) ⇒ Object
Add an ancestor node (base type).
-
#add_descendant(node) ⇒ Object
Add a descendant node (derived type).
-
#initialize(qualified_name, category:, depth: 0) ⇒ TypeHierarchyNode
constructor
A new instance of TypeHierarchyNode.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(qualified_name, category:, depth: 0) ⇒ TypeHierarchyNode
Returns a new instance of TypeHierarchyNode.
319 320 321 322 323 324 325 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 319 def initialize(qualified_name, category:, depth: 0) @qualified_name = qualified_name @category = category @depth = depth @ancestors = [] @descendants = [] end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
317 318 319 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 317 def ancestors @ancestors end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
317 318 319 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 317 def category @category end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
317 318 319 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 317 def depth @depth end |
#descendants ⇒ Object (readonly)
Returns the value of attribute descendants.
317 318 319 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 317 def descendants @descendants end |
#qualified_name ⇒ Object (readonly)
Returns the value of attribute qualified_name.
317 318 319 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 317 def qualified_name @qualified_name end |
Instance Method Details
#add_ancestor(node) ⇒ Object
Add an ancestor node (base type)
329 330 331 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 329 def add_ancestor(node) @ancestors << node unless @ancestors.include?(node) end |
#add_descendant(node) ⇒ Object
Add a descendant node (derived type)
335 336 337 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 335 def add_descendant(node) @descendants << node unless @descendants.include?(node) end |
#to_h ⇒ Hash
Convert to hash for serialization
341 342 343 344 345 346 347 348 349 |
# File 'lib/lutaml/xsd/type_hierarchy_analyzer.rb', line 341 def to_h { qualified_name: @qualified_name, category: @category, depth: @depth, ancestors: @ancestors.map(&:to_h), descendants: @descendants.map(&:to_h), } end |