File Coverage

lib/Archive/Lha/Stream/String.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition n/a
subroutine 7 8 87.5
pod 3 3 100.0
total 34 37 91.8


line stmt bran cond sub pod time code
1             package Archive::Lha::Stream::String;
2            
3 2     2   56552 use strict;
  2         5  
  2         83  
4 2     2   11 use warnings;
  2         3  
  2         157  
5 2     2   13 use Carp;
  2         5  
  2         177  
6 2     2   14 use bytes;
  2         5  
  2         12  
7 2     2   95 use base qw( Archive::Lha::Stream::Base );
  2         4  
  2         928  
8            
9             sub open {
10 3     3 1 14 my ($self, %options) = @_;
11            
12 3 50       21 $self->{string} = $options{string} or croak "String is missing";
13 3         10 $self->{length} = length( $options{string} );
14 3         10 $self->{pos} = 0;
15             }
16            
17 0     0 1 0 sub close { return }
18            
19             sub read {
20 47     47 1 529 my ($self, $length) = @_;
21            
22 47         187 my $str = substr( $self->{string}, $self->{pos}, $length );
23 47         91 $self->{pos} += $length;
24 47         629 return $str;
25             }
26            
27             1;
28            
29             __END__