File Coverage

blib/lib/Image/Select/Array.pm
Criterion Covered Total %
statement 15 38 39.4
branch 0 8 0.0
condition 0 3 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 56 37.5


line stmt bran cond sub pod time code
1             package Image::Select::Array;
2              
3 2     2   69786 use base qw(Image::Select);
  2         10  
  2         993  
4 2     2   14 use strict;
  2         4  
  2         39  
5 2     2   11 use warnings;
  2         3  
  2         59  
6              
7 2     2   11 use Class::Utils qw(set_params);
  2         4  
  2         84  
8 2     2   11 use Error::Pure qw(err);
  2         3  
  2         530  
9              
10             our $VERSION = 0.05;
11              
12             sub new {
13 0     0 1   my ($class, @params) = @_;
14              
15             # Create object.
16 0           my $self = bless {}, $class;
17              
18             # Debug.
19 0           $self->{'debug'} = 0;
20              
21             # Loop.
22 0           $self->{'loop'} = 0;
23              
24             # Image list.
25 0           $self->{'image_list'} = [];
26              
27             # Image type.
28 0           $self->{'type'} = 'bmp';
29              
30             # Sizes.
31 0           $self->{'height'} = 1080;
32 0           $self->{'width'} = 1920;
33              
34             # Process params.
35 0           set_params($self, @params);
36              
37             # Check type.
38 0 0         if (defined $self->{'type'}) {
39 0           $self->_check_type($self->{'type'});
40             }
41              
42             # Check images array.
43 0 0 0       if (! defined $self->{'image_list'}
44             || ref $self->{'image_list'} ne 'ARRAY') {
45              
46 0           err "Parameter 'image_list' must be reference to array ".
47             'with images.';
48             }
49              
50             # Check images.
51 0 0         if (! @{$self->{'image_list'}}) {
  0            
52 0           err 'No images.';
53             }
54              
55             # Check images path.
56 0           foreach my $image (@{$self->{'image_list'}}) {
  0            
57 0 0         if (! -r $image) {
58 0           err "Image '$image' doesn't readable.";
59             }
60             }
61              
62             # Images to select.
63 0           $self->{'_images_to_select'} = $self->{'image_list'};
64 0           $self->{'_images_index'} = 0;
65              
66             # Object.
67 0           return $self;
68             }
69              
70             1;
71              
72             __END__