File Coverage

web/cgi-bin/yatt.lib/YATT/Class/ArrayScanner.pm
Criterion Covered Total %
statement 35 38 92.1
branch 5 10 50.0
condition 2 4 50.0
subroutine 10 12 83.3
pod 0 8 0.0
total 52 72 72.2


line stmt bran cond sub pod time code
1             # -*- mode: perl; coding: utf-8 -*-
2             package YATT::Class::ArrayScanner;
3 7     7   29 use strict;
  7         10  
  7         407  
4 7     7   23 use warnings FATAL => qw(all);
  7         8  
  7         157  
5 7     7   18 use base qw(YATT::Class::Configurable);
  7         8  
  7         428  
6 7     7   27 use YATT::Fields qw(^cf_array cf_index);
  7         6  
  7         32  
7              
8             sub readable {
9 9546     9546 0 8467 (my MY $path, my ($more)) = @_;
10 9546 50       13110 return unless defined $path->{cf_index};
11 9546   50     22004 $path->{cf_index} + ($more || 0) < @{$path->{cf_array}};
  9546         29579  
12             }
13              
14             sub read {
15 818     818 0 746 (my MY $path) = @_;
16 818 50       1361 return undef unless defined $path->{cf_index};
17 818         1228 my $value = $path->{cf_array}->[$path->{cf_index}];
18 818         2059 $path->after_read($path->{cf_index}++);
19 818         1438 $value;
20             }
21              
22 3     3 0 6 sub after_read {}
23 0     0 0 0 sub after_next {}
24              
25             sub current {
26 5711     5711 0 4527 (my MY $path, my ($offset)) = @_;
27 5711 50       7685 return undef unless defined $path->{cf_index};
28 5711   50     22708 $path->{cf_array}->[$path->{cf_index} + ($offset || 0)]
29             }
30              
31             sub next {
32 1699     1699 0 1522 (my MY $path) = @_;
33 1699 50       2596 return undef unless defined $path->{cf_index};
34 1699         2214 my $val = $path->{cf_array}->[$path->{cf_index}++];
35 1699         2765 $path->after_next;
36 1699         4566 $val;
37             }
38              
39             sub go_next {
40 89     89 0 140 (my MY $path) = @_;
41 89 50       255 return undef unless defined $path->{cf_index};
42 89         141 $path->{cf_index}++;
43 89         207 $path->after_next;
44 89         169 $path;
45             }
46              
47             sub peek {
48 0     0 0   (my MY $path, my ($pos)) = @_;
49 0           $path->{cf_array}[$pos];
50             }
51              
52             1;