Repository::Simple::Node - Repository nodes
The following code can be found in ex/print_nodes.pl:
use Repository::Simple; sub print_node; my $repository = Repository::Simple->attach( FileSystem => root => $ARGV[0], ); my $node = $repository->root_node; print_node($node, 0); sub print_node { my ($node, $depth) = @_; print "\t" x $depth, " * ", $node->name, "\n"; for my $child ($node->nodes) { print_node($child, $depth + 1); } for my $p ($node->properties) { print "\t" x $depth, "\t * ", $p->name, " = ", $p->value, "\n"; } }
Each instance of this class describes a node in a repository. A node is basically a unit of information described by a path.
To retrieve an instance of this type, you never construct this object directly. Instead, use one of the node access methods in Repository::Simple and Repository::Simple::Node:
my $root = $repository->root_node; my @children = $root->nodes;
Returns the Repository::Simple object to which this node belongs.
Fetch the node that is the parent of this node. This will always return a node, even for the root node. The root node is the parent of itself.
If you consider time travel, you may wish to stop yourself before you think too hard on the implications and gross yourself out.
Fetch the name of the node. This will always be the last element of the node's path. That is, if the path of the node is:
/foo/bar/baz
then the name of the node is:
baz
In this API it has been decided that the root node will be represented by the string "/" to match with the normal Unix practice of naming the root tree object. The root node must have this name and no other node may have this name.
This returns the full path from the root of the tree to this node.
Returns all the child nodes of this node.
Returns all the proeprties of this node.
Returns the Repository::Simple::Type::Node object describing the node.
Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>
Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
To install Repository::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Repository::Simple
CPAN shell
perl -MCPAN -e shell install Repository::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.