File Coverage

blib/lib/PDF/Builder/Resource/ColorSpace.pm
Criterion Covered Total %
statement 36 36 100.0
branch 5 8 62.5
condition 1 3 33.3
subroutine 10 10 100.0
pod 3 4 75.0
total 55 61 90.1


line stmt bran cond sub pod time code
1             package PDF::Builder::Resource::ColorSpace;
2              
3 2     2   2609 use base 'PDF::Builder::Basic::PDF::Array';
  2         6  
  2         228  
4              
5 2     2   13 use strict;
  2         4  
  2         45  
6 2     2   10 use warnings;
  2         4  
  2         122  
7             #no warnings qw[ deprecated recursion uninitialized ];
8              
9             our $VERSION = '3.023'; # VERSION
10             our $LAST_UPDATE = '3.021'; # manually update whenever code is changed
11              
12 2     2   12 use PDF::Builder::Basic::PDF::Utils;
  2         4  
  2         174  
13 2     2   14 use PDF::Builder::Util;
  2         4  
  2         288  
14 2     2   15 use Scalar::Util qw(weaken);
  2         12  
  2         649  
15              
16             =head1 NAME
17              
18             PDF::Builder::Resource::ColorSpace - Base class for PDF color spaces
19              
20             =head1 METHODS
21              
22             =over
23              
24             =item $cs = PDF::Builder::Resource::ColorSpace->new($pdf, $key, %opts)
25              
26             =item $cs = PDF::Builder::Resource::ColorSpace->new($pdf, $key)
27              
28             Returns a new colorspace object, base class for all colorspaces.
29              
30             =cut
31              
32             sub new {
33 1     1 1 3 my ($class, $pdf, $key, %opts) = @_;
34              
35 1 50       3 $class = ref $class if ref $class;
36 1         5 my $self = $class->SUPER::new();
37 1 50       7 $pdf->new_obj($self) unless $self->is_obj($pdf);
38 1   33     7 $self->name($key || pdfkey());
39 1         3 $self->{' apipdf'} = $pdf;
40 1         4 weaken $self->{' apipdf'};
41              
42 1         4 return $self;
43             }
44              
45             =item $name = $res->name($name)
46              
47             =item $name = $res->name()
48              
49             Returns or sets the Name of the resource.
50              
51             =cut
52              
53             sub name {
54 3     3 1 6 my ($self, $name) = @_;
55              
56 3 100       9 if (defined $name) {
57 1         2 $self->{' name'} = $name;
58             }
59 3         21 return $self->{' name'};
60             }
61              
62             sub type {
63 1     1 0 2 my ($self, $type) = @_;
64              
65 1 50       3 if (defined $type) {
66 1         2 $self->{' type'} = $type;
67             }
68 1         3 return $self->{' type'};
69             }
70              
71             =item @param = $cs->param(@param)
72              
73             Returns properly formatted color-parameters based on the colorspace.
74              
75             =cut
76              
77             sub param {
78 1     1 1 18 my $self = shift;
79              
80 1         12 return (@_);
81             }
82              
83             #sub outobjdeep {
84             # my ($self, @opts) = @_;
85             #
86             # foreach my $k (qw/ api apipdf /) {
87             # $self->{" $k"} = undef;
88             # delete($self->{" $k"});
89             # }
90             # return $self->SUPER::outobjdeep(@opts);
91             #}
92              
93             =back
94              
95             =cut
96              
97             1;