File Coverage

blib/lib/PDF/API2/Resource/XObject/Form/BarCode/codabar.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 2 50.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package PDF::API2::Resource::XObject::Form::BarCode::codabar;
2              
3 2     2   996 use base 'PDF::API2::Resource::XObject::Form::BarCode';
  2         5  
  2         687  
4              
5 2     2   16 use strict;
  2         4  
  2         41  
6 2     2   12 use warnings;
  2         5  
  2         369  
7              
8             our $VERSION = '2.045'; # VERSION
9              
10             sub new {
11 1     1 1 4 my ($class, $pdf, %options) = @_;
12 1         8 my $self = $class->SUPER::new($pdf, %options);
13              
14 1         14 my @bars = $self->encode($options{'-code'});
15              
16 1         8 $self->drawbar([@bars], $options{'caption'});
17              
18 1         5 return $self;
19             }
20              
21             my $codabar = q|0123456789-$:/.+ABCD|;
22              
23             my @barcodabar = qw(
24             11111221 11112211 11121121 22111111 11211211
25             21111211 12111121 12112111 12211111 21121111
26             11122111 11221111 21112121 21211121 21212111
27             11212121 aabbabaa ababaaba ababaaba aaabbbaa
28             );
29              
30             sub encode_char {
31 17     17 0 29 my $self = shift();
32 17         24 my $char = uc shift();
33 17         53 return $barcodabar[index($codabar, $char)];
34             }
35              
36             1;