This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move the modules, tests, prove and Changes file from lib/ to
[perl5.git] / ext / Test / Harness / lib / TAP / Parser / Iterator / Array.pm
CommitLineData
b965d173
NC
1package TAP::Parser::Iterator::Array;
2
3use strict;
b965d173 4use vars qw($VERSION @ISA);
f7c69158
NC
5
6use TAP::Parser::Iterator ();
7
b965d173
NC
8@ISA = 'TAP::Parser::Iterator';
9
10=head1 NAME
11
f7c69158 12TAP::Parser::Iterator::Array - Internal TAP::Parser array Iterator
b965d173
NC
13
14=head1 VERSION
15
f7c69158 16Version 3.13
b965d173
NC
17
18=cut
19
f7c69158 20$VERSION = '3.13';
b965d173
NC
21
22=head1 SYNOPSIS
23
f7c69158 24 # see TAP::Parser::IteratorFactory for preferred usage
b965d173 25
f7c69158
NC
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);
b965d173
NC
30 my $line = $it->next;
31
b965d173
NC
32=head1 DESCRIPTION
33
f7c69158
NC
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.
b965d173 37
f7c69158 38=head1 METHODS
b965d173
NC
39
40=head2 Class Methods
41
42=head3 C<new>
43
f7c69158 44Create an iterator. Takes one argument: an C<$array_ref>
b965d173
NC
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
f7c69158
NC
68# new() implementation supplied by TAP::Object
69
70sub _initialize {
71 my ( $self, $thing ) = @_;
b965d173 72 chomp @$thing;
f7c69158
NC
73 $self->{idx} = 0;
74 $self->{array} = $thing;
75 $self->{exit} = undef;
76 return $self;
b965d173
NC
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;
f7c69158
NC
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