Module: Tree::PathAlgorithms

Includes:
KeyProperty, UpTreeAlgorithms
Included in:
Pool
Defined in:
lib/modular_tree/algorithms.rb

Instance Method Summary collapse

Methods included from UpTreeAlgorithms

#ancestors, #ancestry, #depth

Methods included from BranchesProperty

#bare?, #branches, #each_branch

Methods included from NodeProperty

#node, #node_value

Methods included from KeyProperty

#key

Instance Method Details

#lookup(key) ⇒ Object

TODO

Raises:

  • (NotImplementedError)


332
# File 'lib/modular_tree/algorithms.rb', line 332

def lookup(key) = raise NotImplementedError

#pathObject



319
# File 'lib/modular_tree/algorithms.rb', line 319

def path = @path ||= ancestry[1..-1]&.map(&:key)&.join(separator) || ""

#search(*args, this: true, &block) ⇒ Object



322
323
324
325
326
327
328
329
# File 'lib/modular_tree/algorithms.rb', line 322

def search(*args, this: true, &block)
  matcher = Matcher.new(*args, &block)
  curr = this ? self : branch
  while curr
    return curr if matcher.match?(curr)
    curr = curr.branch
  end
end

#separatorObject



316
# File 'lib/modular_tree/algorithms.rb', line 316

def separator = @separator ||= parent&.separator || ::Tree.separator

#separator=(s) ⇒ Object



317
# File 'lib/modular_tree/algorithms.rb', line 317

def separator=(s) @separator = s end

#uidObject



320
# File 'lib/modular_tree/algorithms.rb', line 320

def uid() @uid ||= [parent&.uid, key].compact.join(separator) end