SAC/Selector/Conditional.pm

filter: Statementstmt 100% 26 / 26 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 88.8% 40 / 45 CC 4 SCAR 5.1
CC
4
Cov
88%
Condition
2.1
SimpleSelector
2.1
new
2.0
CRAP 1.7
« SAC/Condition/Lang.pm ↑ Summary SAC/Selector/Descendant.pm »
1
2 ###
3 # CSS::SAC::Selector::Conditional - SAC ConditionalSelector
4 # Robin Berjon <robin@knowscape.com>
5 # 24/02/2001
6 ###
7
8 package CSS::SAC::Selector::Conditional;
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶$VERSION = $CSS::SAC::VERSION || '0.03';
Condition50%1/2
$CSS::SAC::VERSION || '0.03'
l!l
02
MC/DC0%0/1
$CSS::SAC::VERSION || '0.03'
$CSS::SAC::VERSION
Truth table50%1/2
A
A= $CSS::SAC::VERSION
Aresult
11
00
12
13 2 ▶use base qw(CSS::SAC::Selector::Simple);
Subroutine BEGIN: called CC=1 SCAR=0.0
14
15
16 #---------------------------------------------------------------------#
17 # build the fields for an array based object
18 #---------------------------------------------------------------------#
19 2 ▶use Class::ArrayObjects extend => {
Subroutine BEGIN: called CC=1 SCAR=0.0
20 class => 'CSS::SAC::Selector::Simple',
21 with => [qw(
22 _selector_
23 _condition_
24 )],
25 2 };
26 #---------------------------------------------------------------------#
27
28
29
30
31 ### Constructor #######################################################
32 # #
33 # #
34
35
36 #---------------------------------------------------------------------#
37 # CSS::SAC::Selector::Conditional->new($type,$selector,$condition)
38 # creates a new sac ConditionalSelector object
39 #---------------------------------------------------------------------#
40 34 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
41 34 ▶ my $class = ref($_[0])?ref(shift):shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 34 34
42 34 my $type = shift;
43 34 my $selector = shift;
44 34 my $condition = shift;
45
46 # create a selector
47 34 my $csel = $class->SUPER::new($type);
48
49 # add our fields
50 34 $csel->[_condition_] = $condition;
51 34 $csel->[_selector_] = $selector;
52
53 34 return $csel;
54 }
55 #---------------------------------------------------------------------#
56
57
58 # #
59 # #
60 ### Constructor #######################################################
61
62
63
64 ### Accessors #########################################################
65 # #
66 # #
67
68 2 *CSS::SAC::Selector::Conditional::getCondition = \&Condition;
69 2 *CSS::SAC::Selector::Conditional::getSimpleSelector = \&SimpleSelector;
70
71 #---------------------------------------------------------------------#
72 # my $cond = $csel->Condition()
73 # $csel->Condition($cond)
74 # get/set the selector's condition
75 #---------------------------------------------------------------------#
76 34 ▶sub Condition {
Subroutine Condition: called CC=2 SCAR=7.6
Pod documented
77 34 ▶ (@_==2) ? $_[0]->[_condition_] = $_[1] :
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 34 34
78 $_[0]->[_condition_];
79 }
80 #---------------------------------------------------------------------#
81
82
83 #---------------------------------------------------------------------#
84 # my $cond = $csel->SimpleSelector()
85 # $csel->SimpleSelector($cond)
86 # get/set the selector's simple selector
87 #---------------------------------------------------------------------#
88 34 ▶sub SimpleSelector {
Subroutine SimpleSelector: called CC=2 SCAR=7.6
Pod documented
89 34 ▶ (@_==2) ? $_[0]->[_selector_] = $_[1] :
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 34 34
90 $_[0]->[_selector_];
91 }
92 #---------------------------------------------------------------------#
93
94
95 # #
96 # #
97 ### Accessors #########################################################
98
99
100
101 2 1;
102
103 =pod
104
105 =head1 NAME
106
107 CSS::SAC::Selector::Conditional - SAC ConditionalSelector
108
109 =head1 SYNOPSIS
110
111 see CSS::SAC::Selector
112
113 =head1 DESCRIPTION
114
115 This is a subclass of CSS::SAC::Selector::Simple, look there for more
116 documentation. This class adds the following methods (which also exist
117 in spec style, simply prepend them with 'get'):
118
119 =head1 METHODS
120
121 =over
122
123 =item * CSS::SAC::Selector::Conditional->new($type,$selector,$condition)
124 =item * $sel->new($type,$selector,$condition)
125
126 Creates a new conditional selector.
127
128 =item * $csel->Condition([$cond])
129
130 get/set the selector's condition
131
132 =item * $csel->SimpleSelector([$cond])
133
134 get/set the selector's simple selector
135
136 =back
137
138 =head1 AUTHOR
139
140 Robin Berjon <robin@knowscape.com>
141
142 This module is licensed under the same terms as Perl itself.
143
144 =cut
145
146
« SAC/Condition/Lang.pm ↑ Summary SAC/Selector/Descendant.pm »