Mecabist/Iter.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 49 CC 2 SCAR 10.6
CC
2
Cov
0%
doc
6.0
has_next
2.0
has_prev
2.0
CRAP 2.9
1 package Text::Mecabist::Iter;
2 use strict;
3 use warnings;
4 use Moo::Role;
5  
6 has index => (is => 'rw', default => 0);
7 has skip => (is => 'rw', default => 0);
8 has last => (is => 'rw', default => 0);
9  
10 my $doc;
11 sub doc {
12 my $self = shift;
13 $doc = shift if @_;
14 $doc;
15 }
16  
17 sub has_next {
18 my $self = shift;
19 $self->index < $self->doc->count - 1;
20 }
21  
22 sub has_prev {
23 my $self = shift;
24 $self->index > 0;
25 }
26  
27 sub next {
28 my $self = shift;
29 $self->has_next && $self->doc->nodes->[$self->index + 1];
30 }
31  
32 sub prev {
33 my $self = shift;
34 $self->has_prev && $self->doc->nodes->[$self->index - 1];
35 }
36  
37 1;