Tree::...dByPath(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Tree::Simple::Visitor::FindByPath β€” the manual, but make it cute πŸ’–

okay bestie, so this is one of those User Contributed Perl Documentation pages, and it's literally about a visitor that goes hunting through a Tree::Simple hierarchy to find one specific node by following a path. it's giving detective energy fr fr πŸ”βœ¨


✨ NAME ✨

Tree::Simple::Visitor::FindByPath β€” a Visitor for finding an element in a Tree::Simple hierarchy with a path πŸ¦‹


🌸 SYNOPSIS 🌸

  use Tree::Simple::Visitor::FindByPath;

  # create a visitor object
  my $visitor = Tree::Simple::Visitor::FindByPath->new();

  # set the search path for our tree
  $visitor->setSearchPath(qw(1 1.2 1.2.2));

  # pass the visitor to a tree
  $tree->accept($visitor);

  # fetch the result, which will
  # be the Tree::Simple object that
  # we have found, or undefined
  my $result = $visitor->getResult() || die "No Tree found";

  # our result's node value should match
  # the last element in our path
  print $result->getNodeValue(); # this should print 1.2.2

like, you hand it a path, you hand it a tree, and it walks down and hands you back the node. periodt πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so picture this: you've got a path, you've got a Tree::Simple hierarchy, and this Visitor will attempt to find the node specified by the path. that's the whole vibe. no cap 🫢


πŸ‘‘ METHODS πŸ‘‘

  • new β€” there are no arguments to the constructor, the object will be in its default state. you can use the setSearchPath and setNodeFilter methods to customize its behavior. main character customization arc ✨
  • includeTrunk ($boolean) β€” based upon the value of $boolean, this will tell the visitor to include the trunk of the tree in the search as well. yes, the trunk. the whole tree gets a vibe check 🌳
  • setSearchPath (@path) β€” this is the path we will attempt to follow down the tree. we will do a stringified comparison of each element of the path and the current tree's node (or the value returned by the node filter if it is set). so like, stringify-and-compare, that's the whole method 🧚
  • setNodeFilter ($filter_function) β€” this method accepts a CODE reference as its $filter_function argument and throws an exception if it is not a code reference. this code reference is used to filter the tree nodes as they are collected. this can be used to customize output, or to gather specific information from a more complex tree node. the filter function should accept a single argument, which is the current Tree::Simple object. not me gatekeeping non-code-refs... it literally throws 😭
  • visit ($tree) β€” this is the method that is used by Tree::Simple's accept method. it can also be used on its own, it requires the $tree argument to be a Tree::Simple object (or derived from a Tree::Simple object), and will throw and exception otherwise. (yes bestie, the original says "throw and exception", we're keeping the typo, it's iconic πŸ’€)
  • getResult β€” this method will return the tree found at the specified path (set by the setSearchPath method) or undef if no tree is found. so like, found it or undef, no in-between πŸ”₯
  • getResults β€” this method will return the tree's that make up the path specified in setSearchPath. in the case of a failed search, this can be used to find the elements which did successfully match along the way. consolation prize but make it useful 🎁

πŸ“¦ Repository πŸ“¦

<https://github.com/ronsavage/Tree-Simple-VisitorFactory>


🫢 SUPPORT 🫢

bugs should be reported via the CPAN bug tracker at

<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>

go tell them about the bugs bestie, they wanna know πŸ’Œ

🌈 CODE COVERAGE 🌈

see the CODE COVERAGE section in Tree::Simple::VisitorFactory for more information. iykyk πŸ‘€


πŸ¦‹ SEE ALSO πŸ¦‹

these Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module, you should refer to that module for more information. the family tree of visitors, literally πŸŒ³πŸ’œ


🌸 AUTHOR 🌸

stevan little, <stevan@iinteractive.com>


Copyright 2004, 2005 by Infinity Interactive, Inc.

<http://www.iinteractive.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page bestie, slayed πŸ’…βœ¨

this was perl v5.36.0, dated 2022-11-19, from Tree::...dByPath(3pm) β€” mwah, go find some nodes, you got this πŸŽ€πŸ¦‹πŸ’–
πŸ“¦ where this page comes from