Module: Tree::PathAlgorithms
Instance Method Summary
collapse
#ancestors, #depth, #parents
#bare?, #branches, #each_branch
#node, #node_value
#key
Instance Method Details
#lookup(key) ⇒ Object
337
|
# File 'lib/modular_tree/algorithms.rb', line 337
def lookup(key) = raise NotImplementedError
|
#path ⇒ Object
324
|
# File 'lib/modular_tree/algorithms.rb', line 324
def path = @path ||= ancestry[1..-1]&.map(&:key)&.join(separator) || ""
|
#search(*args, this: true, &block) ⇒ Object
327
328
329
330
331
332
333
334
|
# File 'lib/modular_tree/algorithms.rb', line 327
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
|
#separator ⇒ Object
321
|
# File 'lib/modular_tree/algorithms.rb', line 321
def separator = @separator ||= parent&.separator || ::Tree.separator
|
#separator=(s) ⇒ Object
322
|
# File 'lib/modular_tree/algorithms.rb', line 322
def separator=(s) @separator = s end
|
#uid ⇒ Object
325
|
# File 'lib/modular_tree/algorithms.rb', line 325
def uid() @uid ||= [parent&.uid, key].compact.join(separator) end
|