File Coverage

blib/lib/Getopt/EX/Util.pm
Criterion Covered Total %
statement 8 22 36.3
branch n/a
condition 0 4 0.0
subroutine 3 7 42.8
pod n/a
total 11 33 33.3


line stmt bran cond sub pod time code
1             package Getopt::EX::Util;
2              
3             our $VERSION = "3.03";
4              
5 9     9   88 use v5.14;
  9         24  
6 9     9   38 use warnings;
  9         28  
  9         425  
7              
8 9     9   46 use Exporter 'import';
  9         14  
  9         2167  
9             our @EXPORT = qw();
10             our %EXPORT_TAGS = ();
11             our @EXPORT_OK = qw();
12             our @ISA = qw();
13              
14             package Getopt::EX::ToggleValue {
15             sub new {
16 0     0     my $class = shift;
17 0           my $obj = bless {}, $class;
18 0           my %opt = @_;
19 0   0       $obj->{VALUE} = $opt{value} // 1;
20 0   0       $obj->{CURRENT} = $obj->{INIT} = $opt{init} // 0;
21 0           $obj;
22             }
23             sub toggle {
24 0     0     my $obj = shift;
25 0           my $prev = $obj->{CURRENT};
26 0           $obj->{CURRENT} ^= $obj->{VALUE};
27 0           $prev;
28             }
29             sub value {
30 0     0     my $obj = shift;
31 0           $obj->{CURRENT};
32             }
33             sub reset {
34 0     0     my $obj = shift;
35 0           $obj->{CURRENT} = $obj->{INIT};
36             }
37             }
38              
39             1;