File Coverage

blib/lib/PDF/API2/Resource/ColorSpace.pm
Criterion Covered Total %
statement 36 36 100.0
branch 5 8 62.5
condition 4 9 44.4
subroutine 10 10 100.0
pod 3 4 75.0
total 58 67 86.5


line stmt bran cond sub pod time code
1             package PDF::API2::Resource::ColorSpace;
2              
3 2     2   2606 use base 'PDF::API2::Basic::PDF::Array';
  2         6  
  2         224  
4              
5 2     2   15 use strict;
  2         5  
  2         43  
6 2     2   9 use warnings;
  2         3  
  2         95  
7              
8             our $VERSION = '2.045'; # VERSION
9              
10 2     2   13 use PDF::API2::Basic::PDF::Utils;
  2         8  
  2         159  
11 2     2   14 use PDF::API2::Util;
  2         4  
  2         314  
12 2     2   15 use Scalar::Util qw(weaken);
  2         4  
  2         618  
13              
14             =head1 NAME
15              
16             PDF::API2::Resource::ColorSpace - Base class for PDF color spaces
17              
18             =head1 METHODS
19              
20             =over
21              
22             =item $cs = PDF::API2::Resource::ColorSpace->new $pdf, $key, %parameters
23              
24             Returns a new colorspace object. base class for all colorspaces.
25              
26             =cut
27              
28             sub new {
29 1     1 1 3 my ($class, $pdf, $key) = @_;
30              
31 1 50       3 $class = ref($class) if ref($class);
32 1         5 my $self = $class->SUPER::new();
33 1 50       7 $pdf->new_obj($self) unless $self->is_obj($pdf);
34 1   33     7 $self->name($key || pdfkey());
35 1         2 $self->{' apipdf'} = $pdf;
36 1         4 weaken $self->{' apipdf'};
37              
38 1         2 return $self;
39             }
40              
41             =item $name = $res->name $name
42              
43             Returns or sets the Name of the resource.
44              
45             =cut
46              
47             sub name {
48 3     3 1 6 my $self = shift();
49 3 100 66     12 if (@_ and defined $_[0]) {
50 1         2 $self->{' name'} = $_[0];
51             }
52 3         17 return $self->{' name'};
53             }
54              
55             sub type {
56 1     1 0 2 my $self = shift();
57 1 50 33     7 if (@_ and defined $_[0]) {
58 1         3 $self->{' type'} = $_[0];
59             }
60 1         2 return $self->{' type'};
61             }
62              
63             =item @param = $cs->param @param
64              
65             Returns properly formatted color-parameters based on the colorspace.
66              
67             =cut
68              
69             sub param {
70 1     1 1 2 my $self = shift();
71 1         18 return @_;
72             }
73              
74             =back
75              
76             =cut
77              
78             1;