TPath::Attributes::Standard - the standard collection of attributes available to any forester by default
version 0.011
TPath::Attributes::Standard provides the attributes available to all foresters. TPath::Attributes::Standard is a role which is composed into TPath::Forester.
TPath::Attributes::Standard
@true
Returns a value, 1, evaluating to true.
@false
Returns a value, undef, evaluating to false.
undef
@this
Returns the node itself.
@uid
Returns a string representing the unique path in the tree leading to this node. This consists of the index of the node among its parent's children concatenated to the uid of its parent with / as a separator. The uid of the root node is always /. That of its second child is /1. That of the first child of this child is /1/0. And so on.
/
/1
/1/0
@echo(//a)
Returns is parameter. @echo is useful because it can in effect turn anything into an attribute. You want a predicate that passes when a path returns a node set of a particular cardinality?
@echo
//foo[@echo(bar) = 3]
Attribute test expressions like this require that the left and right operands be either attributes or constants, but this is no restriction because @echo turns everything into an attribute.
@leaf
Returns whether the node is without children.
@pick(//foo,1)
Takes a collection and an index and returns the indexed member of the collection.
@size(//foo)
Takes a collection and returns its size.
@size
Returns the size of the tree rooted at the context node.
@width
Returns the number of leave under the context node.
@depth
Returns the number of ancestors of the context node.
Returns the greatest number of generations, inclusive, separating this node from a leaf. Leaf nodes have a height of 1, their parents, 2, etc.
@root
Returns whether the context node is the tree root.
@null
Returns undef. This is chiefly useful as an argument to other attributes. It will always evaluate as false if used as a predicate.
@index
Returns the index of this node among its parent's children, or -1 if it is the root node.
@log('m1','m2','m3','...')
Prints each message argument to the log stream, one per line, and returns 1. See attribute log_stream in TPath::Forester.
log_stream
@id
Returns the id of the current node, if any.
See TPath::Forester
David F. Houghton <dfhoughton@gmail.com>
This software is copyright (c) 2013 by David F. Houghton.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install TPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TPath
CPAN shell
perl -MCPAN -e shell install TPath
For more information on module installation, please visit the detailed CPAN module installation guide.