| 1 | package TPath::Function; | ||||||||||
| 2 | 1 | $TPath::Function::VERSION = '1.007'; | |||||||||
| 3 | # ABSTRACT: implements the functions in expressions such as C<//*[:abs(@foo) = 1]> and C<//*[:sqrt(@bar) == 2]> | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | with 'TPath::Numifiable'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | has f => ( is => 'ro', isa => 'CodeRef', required => 1 ); | |||||||||
| 10 | |||||||||||
| 11 | 1 | has name => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 12 | |||||||||||
| 13 | 1 | has arg => ( is => 'ro', isa => 'TPath::Numifiable', required => 1 ); | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub to_num { | ||||||||
|
Subroutine
to_num: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 0 | my ( $self, $ctx ) = @_; | |||||||||
| 17 | 0 | return $self->f->( $self->arg->to_num($ctx) ); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub to_string { | ||||||||
|
Subroutine
to_string: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 21 | 0 | my $self = shift; | |||||||||
| 22 | 0 | my $s = ':' . $self->name . '('; | |||||||||
| 23 | 0 | ▶ | if ( $self->arg->isa('TPath::Math') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $s .= ' ' . $self->arg->to_string(1) . ' '; | |||||||||
| 25 | } | ||||||||||
| 26 | else { | ||||||||||
| 27 | 0 | $s .= $self->arg->to_string(1); | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | $s .= ')'; | |||||||||
| 30 | 0 | return $s; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||