File Coverage

blib/lib/Games/Solitaire/BlackHole/Solver/_BoardsStream.pm
Criterion Covered Total %
statement 14 36 38.8
branch 0 2 0.0
condition n/a
subroutine 5 9 55.5
pod n/a
total 19 47 40.4


line stmt bran cond sub pod time code
1             package Games::Solitaire::BlackHole::Solver::_BoardsStream;
2             $Games::Solitaire::BlackHole::Solver::_BoardsStream::VERSION = '0.18.0';
3 10     10   319692 use strict;
  10         20  
  10         341  
4 10     10   48 use warnings;
  10         21  
  10         475  
5 10     10   5025 use autodie;
  10         175807  
  10         63  
6              
7 10     10   67866 use 5.014;
  10         90  
8 10     10   722 use Moo;
  10         8344  
  10         92  
9              
10             has '_boardidx' => ( is => 'rw' );
11             has '_fh' => ( is => 'rw', default => 0, );
12             has '_width' => ( is => 'rw' );
13              
14             sub _board_fn
15             {
16 0     0     my ( $self, ) = @_;
17              
18 0           my $ret = sprintf( "deal%d", $self->_boardidx() );
19 0           $self->_boardidx( 1 + $self->_boardidx() );
20              
21 0           return $ret;
22             }
23              
24             sub _my_open
25             {
26 0     0     my ( $self, $fn ) = @_;
27              
28 0           open my $read_fh, "<", $fn;
29 0           $self->_fh($read_fh);
30              
31 0           return;
32             }
33              
34             sub _fetch
35             {
36 0     0     my ( $self, ) = @_;
37              
38 0           my $s = '';
39 0           read( $self->_fh(), $s, $self->_width );
40 0           my $fn = $self->_board_fn();
41 0 0         if ( eof( $self->_fh() ) )
42             {
43 0           close( $self->_fh() );
44 0           $self->_fh(undef);
45 0           $self->_width(0);
46             }
47 0           return ( $fn, $s, );
48             }
49              
50             sub _reset
51             {
52 0     0     my ( $self, $_fn, $_width, $_boardidx, ) = @_;
53 0           $self->_width($_width);
54 0           $self->_boardidx($_boardidx);
55 0           $self->_my_open($_fn);
56              
57 0           return;
58             }
59              
60             1;
61              
62             __END__