Mode/Single.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 100% 6 / 6 totaltotal 90.4% 38 / 42 SCAR 11.0
CC
3
Cov
88%
as_string
2.1
new
2.0
__ANON__
2.0
CRAP 3.0
« Toolkit/Role/CaseMap.pm ↑ Summary Toolkit/CTCP.pm »
1 package IRC::Mode::Single;
2 2 $IRC::Mode::Single::VERSION = '0.091001';
3 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =pod
7  
8 =for Pod::Coverage FLAG MODE PARAM
9  
10 =cut
11  
12 sub FLAG () { 0 }
13 sub MODE () { 1 }
14 sub PARAM () { 2 }
15  
16 use overload
17 0 ▶ bool => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 2 '""' => 'as_string',
19 2 ▶ fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 sub new {
23 6 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
24 6 ▶ confess "Expected at least a flag and mode"
Branch: 1 branch
BranchTrueFalseTotal
unless @_ >= 2 0 6 6
25 unless @_ >= 2;
26 6 bless [ @_ ], $class
27 }
28  
29 1 ▶sub flag { $_[0]->[FLAG] }
Subroutine flag: called CC=1 SCAR=0.0
Pod documented
30 1 ▶sub char { $_[0]->[MODE] }
Subroutine char: called CC=1 SCAR=0.0
Pod documented
31 1 ▶sub param { $_[0]->[PARAM] }
Subroutine param: called CC=1 SCAR=0.0
Pod documented
32  
33 sub as_string {
34 2 ▶ my ($self) = @_;
Subroutine as_string: called CC=2 SCAR=7.2
Pod documented
35 2 ▶ $self->[FLAG] . $self->[MODE]
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[2] ? : 2 0 2
36 . (defined $self->[PARAM] ? ' '.$self->[PARAM] : '')
37 }
38  
39 1 ▶sub export { [ @{$_[0]} ] }
Subroutine export: called CC=1 SCAR=0.0
Pod documented
40  
41 2 1;
42  
43 =pod
44  
45 =head1 NAME
46  
47 IRC::Mode::Single - A single IRC mode change
48  
49 =head1 SYNOPSIS
50  
51 my $mode = IRC::Mode::Single->new(
52 '+', 'o', 'avenj'
53 );
54  
55 my $flag = $mode->flag;
56 my $mode = $mode->char;
57 my $arg = $mode->param;
58  
59 =head1 DESCRIPTION
60  
61 A simple ARRAY-type object representing a single mode change.
62 These objects stringify into an IRC mode string.
63  
64 Can be used to turn L<IRC::Toolkit::Modes/mode_to_array> mode ARRAYs
65 into objects:
66  
67 for my $mset (@$mode_array) {
68 my $this_mode = IRC::Mode::Single->new( @$mset );
69 . . .
70 }
71  
72 Also see L<IRC::Mode::Set>
73  
74 =head2 new
75  
76 Constructs a new mode change; expects at least a flag and mode.
77  
78 =head2 char
79  
80 The mode character.
81  
82 =head2 flag
83  
84 The '-' or '+' flag for this mode change.
85  
86 =head2 param
87  
88 The parameter attached to the mode, if any.
89  
90 =head2 as_string
91  
92 Produces a mode string (with params attached) for this single mode change.
93  
94 =head2 export
95  
96 Retrieve the backing ARRAY without bless/overload magic.
97  
98 =head1 AUTHOR
99  
100 Jon Portnoy <avenj@cobaltirc.org>
101  
102 =cut
« Toolkit/Role/CaseMap.pm ↑ Summary Toolkit/CTCP.pm »