Builder/Resource/XObject/Form/BarCode/codabar.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 84.2% 32 / 38 CC 3 SCAR 6.5
CC
3
Cov
90%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Builder/Resource/ExtGState.pm ↑ Summary Builder/Basic/PDF/Utils.pm »
1 package PDF::Builder::Resource::XObject::Form::BarCode::codabar;
2  
3 2 ▶use base 'PDF::Builder::Resource::XObject::Form::BarCode';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '3.028'; # VERSION
9 2 our $LAST_UPDATE = '3.027'; # manually update whenever code is changed
10  
11 =head1 NAME
12  
13 PDF::Builder::Resource::XObject::Form::BarCode::codabar - Specific information for CodaBar bar codes
14  
15 Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode>
16  
17 =head1 METHODS
18  
19 =head2 new
20  
21 PDF::Builder::Resource::XObject::Form::BarCode::codabar->new()
22  
23 =over
24  
25 Create a Codabar bar code object. Note that it is invoked from the Builder.pm
26 level method!
27  
28 =back
29  
30 =cut
31  
32 # TBD document code, caption options
33  
34 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod documented
35 1 my ($class, $pdf, %options) = @_;
36 # copy dashed option names to preferred undashed names
37 1 ▶ if (defined $options{'-code'} && !defined $options{'code'}) { $options{'code'} = delete($options{'-code'}); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options{"-code"} and not defined $options{"code"}) 1 0 1
Condition33%1/3
defined $options{"-code"} and not defined $options{"code"}
!ll&&!rl&&r
001
MC/DC0%0/2
defined $options{"-code"} and not defined $options{"code"}
defined $options{"-code"} not defined $options{"code"}
Truth table33%1/3
A and not(B)
A= defined $options{"-code"}B= not defined $options{"code"}
ABresult
0X0
100
111
38  
39 1 my $self = $class->SUPER::new($pdf, %options);
40  
41 1 my @bars = $self->encode($options{'code'});
42  
43 1 $self->drawbar([@bars], $options{'caption'});
44  
45 1 return $self;
46 }
47  
48 # allowed alphabet and translation to bar widths
49 2 my $codabar = q|0123456789-$:/.+ABCD|;
50  
51 2 my @barcodabar = qw(
52 11111221 11112211 11121121 22111111 11211211
53 21111211 12111121 12112111 12211111 21121111
54 11122111 11221111 21112121 21211121 21212111
55 11212121 aabbabaa ababaaba ababaaba aaabbbaa
56 );
57  
58 17 ▶sub encode_char {
Subroutine encode_char: called CC=1 SCAR=0.0
Pod undocumented
59 17 my $self = shift;
60 17 my $char = uc(shift());
61  
62 17 return $barcodabar[index($codabar, $char)];
63 }
64  
65 2 1;
« Builder/Resource/ExtGState.pm ↑ Summary Builder/Basic/PDF/Utils.pm »