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