File Coverage

blib/lib/Regexp/Flow/Result.pm
Criterion Covered Total %
statement 15 16 93.7
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Regexp::Flow::Result;
2 1     1   4 use strict;
  1         2  
  1         31  
3 1     1   4 use warnings;
  1         2  
  1         24  
4              
5 1     1   3171 use Moo;
  1         26361  
  1         6  
6              
7             =head1 NAME
8              
9             Regexp::Flow::Result - container for information about a Regexp match.
10              
11             =head1 DESCRIPTION
12              
13             This is a subclass of C. It adds methods and attributes
14             which are useful to have in the same object.
15              
16             =cut
17              
18             extends 'Regexp::Result';
19              
20             =head1 OVERLOADING
21              
22             In a boolean context, this returns true if the match was a success.
23              
24             =cut
25              
26             use overload
27 1     1   3666 '0+'=>sub{shift->success}; #~ for some reason \&success does not work here
  1     0   1112  
  1         8  
  0         0  
28              
29             =head1 METHODS
30              
31             =head3 success
32              
33             C<1> or C<0>; default C. Indicates if the match was a success.
34              
35             =cut
36              
37             has success => (
38             is => 'rw',
39             default => sub{ undef },
40             );
41              
42             =head3 continue_action
43              
44             C or C; default C. Used to control if C and
45             C continue to operate. See the C method.
46              
47             =cut
48              
49             has continue_action => (
50             is => 'rw',
51             default => sub{'next'},
52             );
53              
54             =head3 last
55              
56             Invoke this method to set C to C<"last">. This
57             prevents further coderefs being executed by
58             C or C.
59             Note that this does not exit the current subroutine.
60              
61             =cut
62              
63             sub last {
64 3     3 1 18 my $self = shift;
65 3         14 $self->continue_action('last');
66 3         6 return $self;
67             }
68              
69             =head3 string
70              
71             The string before the regexp was executed. Note that when globally
72             matching, the string is the same for all results - the string is only
73             changed when all the matches have been found.
74              
75             =cut
76              
77             has string => (
78             is => 'rw',
79             default => sub{ undef },
80             );
81              
82             =head3 re
83              
84             The regular expression in use.
85              
86             =cut
87              
88             has re => (
89             is => 'rw',
90             default => sub{ undef },
91             );
92              
93             =head1 SEE ALSO
94              
95             Regexp::Flow - which uses this module
96             (also for author and copyright information)
97              
98             =cut
99              
100             1;