lib/Archive/Lha/Stream/Hex.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 97.5% 40 / 41 CC 3 SCAR 4.1
CC
3
Cov
97%
open
2.0
read
2.0
BEGIN
1.0
CRAP 1.5
« lib/Archive/Lha/Stream/File.pm ↑ Summary lib/Archive/Lha/Stream/String.pm »
1 package Archive::Lha::Stream::Hex;
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base qw( Archive::Lha::Stream::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 1 ▶sub open {
Subroutine open: called CC=2 SCAR=7.0
Pod documented
9 1 my ($self, %options) = @_;
10
11 1 ▶ croak "Array reference of hex strings is missing" unless ref $options{hex} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $options{"hex"} eq "ARRAY" 0 1 1
12
13 1 my @array = map { pack 'H2', $_ } @{ $options{hex} };
14
15 1 $self->{array} = \@array;
16 1 $self->{length} = scalar @array;
17 1 $self->{pos} = 0;
18 }
19
20 5 ▶sub read {
Subroutine read: called CC=2 SCAR=6.9
Pod documented
21 5 my ($self, $length) = @_;
22
23 5 my $from = $self->{pos};
24 5 my $to = $self->{pos} + $length - 1;
25 5 ▶ $to = $self->{length} - 1 if $to >= $self->{length};
Branch: 1 branch
BranchTrueFalseTotal
if $to >= $self->{"length"} 2 3 5
26 5 my $str = join '', @{ $self->{array} }[$from .. $to];
27 5 $self->{pos} = $to + 1;
28 5 return $str;
29 }
30
31 2 1;
32
33 __END__
« lib/Archive/Lha/Stream/File.pm ↑ Summary lib/Archive/Lha/Stream/String.pm »