NAME
TPath::Attributes::Standard - the standard collection of attributes available to any forester by default
VERSION
version 0.008
DESCRIPTION
TPath::Attributes::Standard
provides the attributes available to all foresters. TPath::Attributes::Standard
is a role which is composed into TPath::Forester.
METHODS
@true
Returns a value, 1, evaluating to true.
@false
Returns a value, undef
, evaluating to false.
@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.
@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?
//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.
@depth
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.
@id
Returns the id of the current node, if any.
REQUIRED METHODS
_kids
See TPath::Forester
children
See TPath::Forester
parent
See TPath::Forester
AUTHOR
David F. Houghton <dfhoughton@gmail.com>
COPYRIGHT AND LICENSE
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.