File Coverage

web/cgi-bin/yatt.lib/YATT/Class/ArrayScanner.pm
Criterion Covered Total %
statement 34 36 94.4
branch 5 10 50.0
condition 2 4 50.0
subroutine 10 12 83.3
pod 0 8 0.0
total 51 70 72.8


line stmt bran cond sub pod time code
1             # -*- mode: perl; coding: utf-8 -*-
2             package YATT::Class::ArrayScanner;
3 7     7   41 use strict;
  7         15  
  7         216  
4 7     7   36 use warnings qw(FATAL all NONFATAL misc);
  7         12  
  7         266  
5 7     7   143 use base qw(YATT::Class::Configurable);
  7         11  
  7         592  
6 7     7   36 use YATT::Fields qw(^cf_array cf_index);
  7         19  
  7         44  
7              
8             sub readable {
9 9546     9546 0 13678 (my MY $path, my ($more)) = @_;
10 9546 50       21592 return unless defined $path->{cf_index};
11 9546   50     32354 $path->{cf_index} + ($more || 0) < @{$path->{cf_array}};
  9546         50623  
12             }
13              
14             sub read {
15 818     818 0 1215 (my MY $path) = @_;
16 818 50       1874 return undef unless defined $path->{cf_index};
17 818         1888 my $value = $path->{cf_array}->[$path->{cf_index}];
18 818         2806 $path->after_read($path->{cf_index}++);
19 818         3152 $value;
20             }
21              
22       3 0   sub after_read {}
23       0 0   sub after_next {}
24              
25             sub current {
26 5711     5711 0 8535 (my MY $path, my ($offset)) = @_;
27 5711 50       11524 return undef unless defined $path->{cf_index};
28 5711   50     35145 $path->{cf_array}->[$path->{cf_index} + ($offset || 0)]
29             }
30              
31             sub next {
32 1699     1699 0 2431 (my MY $path) = @_;
33 1699 50       3857 return undef unless defined $path->{cf_index};
34 1699         3416 my $val = $path->{cf_array}->[$path->{cf_index}++];
35 1699         4517 $path->after_next;
36 1699         7709 $val;
37             }
38              
39             sub go_next {
40 89     89 0 167 (my MY $path) = @_;
41 89 50       264 return undef unless defined $path->{cf_index};
42 89         155 $path->{cf_index}++;
43 89         292 $path->after_next;
44 89         182 $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;