File Coverage

blib/lib/PDF/Builder/Resource/ColorSpace.pm
Criterion Covered Total %
statement 34 36 94.4
branch 5 8 62.5
condition 1 3 33.3
subroutine 9 10 90.0
pod 3 4 75.0
total 52 61 85.2


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