Class: Opencdd::RelationTree

Inherits:
Object
  • Object
show all
Defined in:
lib/opencdd/relation_tree.rb

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ RelationTree

Returns a new instance of RelationTree.



25
26
27
# File 'lib/opencdd/relation_tree.rb', line 25

def initialize(database)
  @database = database
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



23
24
25
# File 'lib/opencdd/relation_tree.rb', line 23

def database
  @database
end

Instance Method Details

#for(root = nil, max_depth: 10) ⇒ Object



29
30
31
32
# File 'lib/opencdd/relation_tree.rb', line 29

def for(root = nil, max_depth: 10)
  roots = root.nil? ? root_relations : [lookup_relation(root)].compact
  roots.map { |r| build_node(r, Set.new, max_depth) }
end