File Coverage

blib/lib/Bio/Polloc/GroupCriteria/operator.pm
Criterion Covered Total %
statement 52 58 89.6
branch 17 24 70.8
condition 1 3 33.3
subroutine 9 11 81.8
pod 7 7 100.0
total 86 103 83.5


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Bio::Polloc::GroupCriteria::operator - An acillary object for Bio::Polloc::GroupCriteria
4              
5             =head1 AUTHOR - Luis M. Rodriguez-R
6              
7             Email lmrodriguezr at gmail dot com
8              
9             =head1 SYNOPSIS
10              
11             # ...
12             $Bio::Polloc::GroupCriteria::operator::cons::OP_CONS->{'KEY1'} = $some_value_1;
13             my $op = Bio::Polloc::GroupCriteria::operator->new(@args);
14             my $res = $op->operate;
15             # ...
16              
17             =cut
18              
19             package Bio::Polloc::GroupCriteria::operator;
20 3     3   16 use base qw(Bio::Polloc::Polloc::Root);
  3         7  
  3         237  
21 3     3   15 use strict;
  3         6  
  3         1933  
22             our $VERSION = 1.0503; # [a-version] from Bio::Polloc::Polloc::Version
23              
24              
25             =head1 APPENDIX
26              
27             Methods provided by the package
28              
29             =head2 new
30              
31             Attempts to initialize a Bio::Polloc::GroupCriteria::operator::* object
32              
33             =head3 Arguments
34              
35             =over
36              
37             =item -type I<str>
38              
39             Type of operator
40              
41             =item -val I<mix>
42              
43             The value of the operator
44              
45             =item -name I<str>
46              
47             A name for the operator
48              
49             =item -operation I<str>
50              
51             The operation itself
52              
53             =item -operators I<refarr>
54              
55             A refarray containing the operators (I<mix>).
56              
57             =back
58              
59             =head3 Returns
60              
61             A L<Bio::Polloc::Locus::repeat> object.
62              
63             =cut
64              
65             sub new {
66 141     141 1 372 my($caller,@args) = @_;
67 141   33     470 my $class = ref($caller) || $caller;
68            
69 141 50       297 if($class !~ m/Bio::Polloc::GroupCriteria::operator::(\S+)/){
70 141         452 my $bme = Bio::Polloc::Polloc::Root->new(@args);
71 141         493 my($type) = $bme->_rearrange([qw(TYPE)], @args);
72            
73 141 50       343 if($type){
74 141         307 $type = Bio::Polloc::GroupCriteria::operator->_qualify_type($type);
75 141 50       587 $class = "Bio::Polloc::GroupCriteria::operator::" . $type if $type;
76             }
77             }
78              
79 141 50       579 if($class =~ m/Bio::Polloc::GroupCriteria::operator::(\S+)/){
80 141         151 my $load = 0;
81 141         224 my $loadtype = $1;
82 141 50       437 if(Bio::Polloc::GroupCriteria::operator->_load_module($class)){
83 141         195 $load = $class;
84             }
85            
86 141 50       253 if($load){
87 141         516 my $self = $load->SUPER::new(@args);
88 141         562 $self->debug("Got the GroupCriteria operator class $load");
89 141         584 my($val, $name, $operation, $operators) = $self->_rearrange([qw(VAL NAME OPERATION OPERATORS)], @args);
90 141         546 $self->type($loadtype);
91 141         294 $self->val($val);
92 141         303 $self->name($name);
93 141         341 $self->operation($operation);
94 141         336 $self->operators($operators);
95 141         415 $self->_initialize(@args);
96 141         827 return $self;
97             }
98            
99 0         0 my $bme = Bio::Polloc::Polloc::Root->new(@args);
100 0         0 $bme->throw("Impossible to load the module", $class);
101             }
102 0         0 my $bme = Bio::Polloc::Polloc::Root->new(@args);
103 0         0 $bme->throw("Impossible to load the proper Bio::Polloc::GroupCriteria::operator class with ".
104             "[".join("; ",@args)."]", $class);
105             }
106              
107             =head2 val
108              
109             Sets/gets the value
110              
111             =cut
112              
113             sub val {
114 141     141 1 170 my($self, $value) = @_;
115 141         151 my $k = '_val';
116 141 100       257 $self->{$k} = $value if defined $value;
117 141         246 return $self->{$k};
118             }
119              
120             =head2 name
121              
122             Sets/gets the name
123              
124             =cut
125              
126             sub name {
127 141     141 1 167 my($self, $value) = @_;
128 141         149 my $k = '_name';
129 141 100       329 $self->{$k} = $value if defined $value;
130 141         200 return $self->{$k};
131             }
132              
133             =head2 operation
134              
135             Sets/gets the operation
136              
137             =cut
138              
139             sub operation {
140 210     210 1 254 my($self, $value) = @_;
141 210         231 my $k = '_operation';
142 210 100       452 $self->{$k} = $value if defined $value;
143 210         442 return $self->{$k};
144             }
145              
146             =head2 operators
147              
148             Sets/gets the operators
149              
150             =cut
151              
152             sub operators {
153 141     141 1 162 my($self, $value) = @_;
154 141         146 my $k = '_operators';
155 141 100       265 $self->{$k} = $value if defined $value;
156 141         210 return $self->{$k};
157             }
158              
159             =head2 type
160              
161             Sets/gets the type of operator
162              
163             =cut
164              
165             sub type {
166 210     210 1 279 my($self, $value) = @_;
167 210         235 my $k = '_type';
168 210 100       536 $self->{$k} = $value if defined $value;
169 210         463 return $self->{$k};
170             }
171              
172             =head2 operate
173              
174             =cut
175              
176 0     0 1 0 sub operate { $_[0]->throw('operate', $_[0], 'Bio::Polloc::Polloc::NotImplementedException') }
177              
178             =head1 INTERNAL METHODS
179              
180             Methods intended to be used only within the scope of Bio::Polloc::*
181              
182             =head2 _qualify_type
183              
184             =cut
185              
186             sub _qualify_type {
187 141     141   179 my($self, $value) = @_;
188 141 50       567 return lc $value if defined $value;
189             }
190              
191             =head2 _initialize
192              
193             =cut
194              
195 0     0     sub _initialize { $_[0]->throw('_initialize', $_[0], 'Bio::Polloc::Polloc::NotImplementedException') }
196              
197             1;