| 1 | package DTL::Fast::Tag::Widthratio; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; use utf8; use warnings FATAL => 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use parent 'DTL::Fast::Tag::Simple'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | $DTL::Fast::TAG_HANDLERS{'widthratio'} = __PACKAGE__; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | ▶ | use DTL::Fast::Utils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | #@Override | ||||||||||||||||||||
| 10 | sub parse_parameters | ||||||||||||||||||||
| 11 | { | ||||||||||||||||||||
| 12 | 3 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
parse_parameters: called CC=4 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | ▶ | if( $self->{'parameter'} =~ /^\s*(.+?)(?:\s+as\s+([^\s]+))?\s*$/s ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | { | ||||||||||||||||||||
| 16 | 3 | $self->{'target_name'} = $2; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 3 | $self->{'sources'} = $self->parse_sources($1); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | die $self->get_parse_error( | ||||||||||||||||||||
| 21 | sprintf( | ||||||||||||||||||||
| 22 | "Three arguments should be passed to widthratio: %s %s" | ||||||||||||||||||||
| 23 | , $self->{'parameter'} // 'undef' | ||||||||||||||||||||
| 24 | 0 | , scalar @{$self->{'sources'}} | |||||||||||||||||||
| 25 | ) | ||||||||||||||||||||
| 26 | 3 | ▶ | ) if scalar @{$self->{'sources'}} != 3; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"parameter"} // "undef"
MC/DC0%0/1
$self->{"parameter"} // "undef"
$self->{"parameter"}
Truth table0%0/2
A
A= $self->{"parameter"}
| |||||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | else | ||||||||||||||||||||
| 29 | { | ||||||||||||||||||||
| 30 | 0 | die die $self->get_parse_error("Unable to parse ratio parameters $self->{'parameter'}"); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 3 | return $self; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | #@Override | ||||||||||||||||||||
| 37 | sub render | ||||||||||||||||||||
| 38 | { | ||||||||||||||||||||
| 39 | 3 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
render: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 40 | 3 | my $context = shift; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 3 | my $sources = $self->{'sources'}; | |||||||||||||||||||
| 43 | 3 | my $result = int( | |||||||||||||||||||
| 44 | $sources->[0]->render($context) | ||||||||||||||||||||
| 45 | / $sources->[1]->render($context) | ||||||||||||||||||||
| 46 | * $sources->[2]->render($context) | ||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 3 | ▶ | if( $self->{'target_name'} ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | { | ||||||||||||||||||||
| 51 | 1 | $context->set($self->{'target_name'} => $result); | |||||||||||||||||||
| 52 | 1 | $result = ''; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 3 | return $result; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 2 | 1; | |||||||||||||||||||