Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / TAP / Parser / Iterator / Array.pm
CommitLineData
3fea05b9 1package TAP::Parser::Iterator::Array;
2
3use strict;
4use vars qw($VERSION @ISA);
5
6use TAP::Parser::Iterator ();
7
8@ISA = 'TAP::Parser::Iterator';
9
10=head1 NAME
11
12TAP::Parser::Iterator::Array - Internal TAP::Parser array Iterator
13
14=head1 VERSION
15
16Version 3.17
17
18=cut
19
20$VERSION = '3.17';
21
22=head1 SYNOPSIS
23
24 # see TAP::Parser::IteratorFactory for preferred usage
25
26 # to use directly:
27 use TAP::Parser::Iterator::Array;
28 my @data = ('foo', 'bar', baz');
29 my $it = TAP::Parser::Iterator::Array->new(\@data);
30 my $line = $it->next;
31
32=head1 DESCRIPTION
33
34This is a simple iterator wrapper for arrays of scalar content, used by
35L<TAP::Parser>. Unless you're subclassing, you probably won't need to use
36this module directly.
37
38=head1 METHODS
39
40=head2 Class Methods
41
42=head3 C<new>
43
44Create an iterator. Takes one argument: an C<$array_ref>
45
46=head2 Instance Methods
47
48=head3 C<next>
49
50Iterate through it, of course.
51
52=head3 C<next_raw>
53
54Iterate raw input without applying any fixes for quirky input syntax.
55
56=head3 C<wait>
57
58Get the wait status for this iterator. For an array iterator this will always
59be zero.
60
61=head3 C<exit>
62
63Get the exit status for this iterator. For an array iterator this will always
64be zero.
65
66=cut
67
68# new() implementation supplied by TAP::Object
69
70sub _initialize {
71 my ( $self, $thing ) = @_;
72 chomp @$thing;
73 $self->{idx} = 0;
74 $self->{array} = $thing;
75 $self->{exit} = undef;
76 return $self;
77}
78
79sub wait { shift->exit }
80
81sub exit {
82 my $self = shift;
83 return 0 if $self->{idx} >= @{ $self->{array} };
84 return;
85}
86
87sub next_raw {
88 my $self = shift;
89 return $self->{array}->[ $self->{idx}++ ];
90}
91
921;
93
94=head1 ATTRIBUTION
95
96Originally ripped off from L<Test::Harness>.
97
98=head1 SEE ALSO
99
100L<TAP::Object>,
101L<TAP::Parser>,
102L<TAP::Parser::Iterator>,
103L<TAP::Parser::IteratorFactory>,
104
105=cut
106