| File: | blib/lib/Text/LTSV/Iterator.pm |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package Text::LTSV::Iterator; | |||||
| 2 | 4 4 4 | 7 2 91 | use strict; | |||
| 3 | 4 4 4 | 8 1 394 | use warnings; | |||
| 4 | ||||||
| 5 | sub new { | |||||
| 6 | 1 | 2 | my ($class, $parser, $handle) = @_; | |||
| 7 | 1 | 8 | return bless { | |||
| 8 | _parser => $parser, | |||||
| 9 | _handle => $handle, | |||||
| 10 | }, $class; | |||||
| 11 | } | |||||
| 12 | ||||||
| 13 | sub has_next { | |||||
| 14 | 4 | 823 | my $self = shift; | |||
| 15 | 4 | 74 | $self->{_handle}->eof ? 0 : 1; | |||
| 16 | } | |||||
| 17 | ||||||
| 18 | sub next { | |||||
| 19 | 3 | 3 | my $self = shift; | |||
| 20 | 3 | 63 | return $self->{_parser}->parse_line( $self->{_handle}->getline ); | |||
| 21 | } | |||||
| 22 | ||||||
| 23 | sub end { | |||||
| 24 | 1 | 18 | shift->{_handle}->close; | |||
| 25 | } | |||||
| 26 | ||||||
| 27 | 1; | |||||