File Coverage

blib/lib/HTML/Barcode/Code128.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 16 16 100.0


line stmt bran cond sub pod time code
1             package HTML::Barcode::Code128;
2 2     2   18995 use Moo;
  2         18706  
  2         9  
3             extends 'HTML::Barcode::1D';
4 2     2   2550 use Barcode::Code128;
  2         3882  
  2         415  
5              
6             our $VERSION = '0.13';
7              
8             has '_code128' => (
9             is => 'ro',
10             default => sub { Barcode::Code128->new },
11             );
12              
13             sub barcode_data {
14 1     1 1 1308 my ($self) = @_;
15 1         7 my $data_str = $self->_code128->barcode($self->text);
16             return [
17 1 100       299 map { $_ eq '#' ? 1 : 0 }
  101         127  
18             split //, $data_str
19             ];
20             }
21              
22             =head1 NAME
23              
24             HTML::Barcode::Code128 - Generate HTML representations of Code 128 barcodes
25              
26             =head1 SYNOPSIS
27              
28             L is required by this class, so please install it first.
29              
30             my $code = HTML::Barcode::Code128->new(text => 'MONKEY');
31             print $code->render;
32              
33             =head1 DESCRIPTION
34              
35             This class allows you to easily create HTML representations of Code 128 barcodes.
36              
37             =begin html
38              
39            

Here is an example of a Code 128 barcode rendered with this module:

40              
41            
MONKEY
42              
43             =end html
44              
45             This B L. You may also use the
46             L from this module in your text.
47             Be sure to provide their full package name.
48             For example:
49              
50             my $text = Barcode::Code128::FNC1 . '00000123455555555558';
51             HTML::Barcode::Code128->new(text => $text)->render;
52              
53             You can read more about Code 128 online (e.g. L).
54              
55             =head1 METHODS
56              
57             =head2 new (%attributes)
58              
59             Instantiate a new HTML::Barcode::Code128 object. The C<%attributes> hash
60             requires the L attribute, and can take any of the other
61             L listed below.
62              
63             =head2 render
64              
65             This is a convenience routine which returns C<< >> tags
66             and the rendered barcode.
67              
68             If you are printing multiple barcodes or want to ensure your C