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