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   40 use strict;
  7         12  
  7         212  
4 7     7   32 use warnings qw(FATAL all NONFATAL misc);
  7         13  
  7         261  
5 7     7   33 use base qw(YATT::Class::Configurable);
  7         15  
  7         560  
6 7     7   36 use YATT::Fields qw(^cf_array cf_index);
  7         12  
  7         44  
7              
8             sub readable {
9 9546     9546 0 13954 (my MY $path, my ($more)) = @_;
10 9546 50       21891 return unless defined $path->{cf_index};
11 9546   50     33119 $path->{cf_index} + ($more || 0) < @{$path->{cf_array}};
  9546         50583  
12             }
13              
14             sub read {
15 818     818 0 1199 (my MY $path) = @_;
16 818 50       1904 return undef unless defined $path->{cf_index};
17 818         1641 my $value = $path->{cf_array}->[$path->{cf_index}];
18 818         3154 $path->after_read($path->{cf_index}++);
19 818         2449 $value;
20             }
21              
22       3 0   sub after_read {}
23       0 0   sub after_next {}
24              
25             sub current {
26 5711     5711 0 8294 (my MY $path, my ($offset)) = @_;
27 5711 50       11986 return undef unless defined $path->{cf_index};
28 5711   50     35514 $path->{cf_array}->[$path->{cf_index} + ($offset || 0)]
29             }
30              
31             sub next {
32 1699     1699 0 2549 (my MY $path) = @_;
33 1699 50       3862 return undef unless defined $path->{cf_index};
34 1699         3563 my $val = $path->{cf_array}->[$path->{cf_index}++];
35 1699         4868 $path->after_next;
36 1699         7776 $val;
37             }
38              
39             sub go_next {
40 89     89 0 167 (my MY $path) = @_;
41 89 50       280 return undef unless defined $path->{cf_index};
42 89         152 $path->{cf_index}++;
43 89         319 $path->after_next;
44 89         220 $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;