File Coverage

blib/lib/Imager/LineTrace/Figure.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             package Imager::LineTrace::Figure;
2 2     2   879 use 5.008001;
  2         7  
  2         80  
3 2     2   12 use strict;
  2         4  
  2         69  
4 2     2   11 use warnings;
  2         6  
  2         462  
5              
6             sub new {
7 11     11 0 1729 my $pkg = shift;
8 11         15 my $args_ref = shift;
9              
10 23         79 my @points = map {
11 11         25 bless $_, 'Imager::LineTrace::Point';
12 11         25 } @{$args_ref->{points}};
13              
14 11         26 my $type = "Undefined";
15 11 100       45 if ( $args_ref->{is_closed} ) {
    100          
    100          
16 1         3 $type = "Polygon";
17             }
18             elsif ( 3 <= scalar(@points) ) {
19 4         11 $type = "Polyline";
20             }
21             elsif ( 2 <= scalar(@points) ) {
22 1         3 $type = "Line";
23             }
24             else {
25 5         9 $type = "Point";
26             }
27              
28 11         92 bless {
29             points => \@points,
30             is_closed => $args_ref->{is_closed},
31             value => $args_ref->{value},
32             type => $type
33             }, $pkg;
34             }
35              
36             1;
37             __END__