| 1 | package Dallycot::AST::Product; | ||||||||||
| 2 | 29 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||
| 3 | |||||||||||
| 4 | # ABSTRACT: Calculates the product of a series of values | ||||||||||
| 5 | |||||||||||
| 6 | 29 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 29 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 29 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 29 | ▶ | use parent 'Dallycot::AST'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 29 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 29 | Readonly my $NUMERIC => ['Numeric']; | |||||||||
| 15 | |||||||||||
| 16 | sub to_string { | ||||||||||
| 17 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 18 | |||||||||||
| 19 | 0 | return "(" . join( "*", map { $_->to_string } @{$self} ) . ")"; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | sub to_rdf { | ||||||||||
| 23 | 0 | ▶ | my($self, $model) = @_; | ||||||||
|
Subroutine
to_rdf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 24 | |||||||||||
| 25 | # | ||||||||||
| 26 | # node -> expression_set -> [ ... ] | ||||||||||
| 27 | # | ||||||||||
| 28 | 0 | return $model -> apply( | |||||||||
| 29 | $model -> meta_uri('loc:product'), | ||||||||||
| 30 | [ @$self ], | ||||||||||
| 31 | {} | ||||||||||
| 32 | ); | ||||||||||
| 33 | # my $bnode = $model->bnode; | ||||||||||
| 34 | # $model -> add_type($bnode, 'loc:Product'); | ||||||||||
| 35 | # | ||||||||||
| 36 | # foreach my $expr (@$self) { | ||||||||||
| 37 | # $model -> add_expression($bnode, $expr); | ||||||||||
| 38 | # } | ||||||||||
| 39 | # return $bnode; | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub execute { | ||||||||||
| 43 | 118 | ▶ | my ( $self, $engine ) = @_; | ||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 44 | |||||||||||
| 45 | 236 | return $engine->collect( map { [ $_, $NUMERIC ] } @$self )->then( | |||||||||
| 46 | sub { | ||||||||||
| 47 | 117 | ▶ | my (@values) = map { $_->value } @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 48 | |||||||||||
| 49 | 117 | my $acc = ( pop @values )->copy; | |||||||||
| 50 | |||||||||||
| 51 | 117 | ▶ | while (@values) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 117 | $acc *= ( pop @values ); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 117 | return Dallycot::Value::Numeric->new($acc); | |||||||||
| 56 | } | ||||||||||
| 57 | 118 | ); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 29 | 1; | |||||||||