blib/lib/Games/Bingo/Column.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 6 / 6 totaltotal 100% 71 / 71 SCAR 13.9
CC
4
Cov
100%
new
2.0
get_random_number
2.0
get_highest_number
2.0
CRAP 4.0
« Build ↑ Summary blib/lib/Games/Bingo/Constants.pm »
1 package Games::Bingo::Column;
2  
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use Games::Bingo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 26 @ISA = qw(Games::Bingo);
10 26 $VERSION = '0.17';
11  
12 sub new {
13 1584 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
14 1584 my $label = shift;
15 1584 my @array = sort _reverse (@_);
16
17 1584 ▶ my $self = bless {
Branch: 1 branch
BranchTrueFalseTotal
$label ? : 1401 183 1584
18 label => $label?$label:0,
19 _array => \@array
20 }, $class;
21 }
22  
23 12517 ▶sub _reverse { $b <=> $a }
Subroutine _reverse: called CC=1 SCAR=0.0
24  
25 sub populate {
26 1300 ▶ my ($self, $value) = @_;
Subroutine populate: called CC=1 SCAR=0.0
Pod documented
27
28 1300 push @{$self->{_array}}, $value;
29
30 1300 @{$self->{_array}} = sort _reverse @{$self->{_array}};
31 }
32  
33 sub get_random_number {
34 1307 ▶ my ($self, $do_splice) = @_;
Subroutine get_random_number: called CC=2 SCAR=6.9
Pod documented
35
36 1307 my $pos = $self->random($self->count_numbers);
37
38 1307 my $number = $self->{_array}->[$pos];
39 1307 ▶ splice(@{$self->{_array}}, $pos, 1) if $do_splice;
Branch: 1 branch
BranchTrueFalseTotal
if $do_splice 1306 1 1307
40
41 1307 return $number;
42 }
43  
44 sub count_numbers {
45 2583 ▶ my $self = shift;
Subroutine count_numbers: called CC=1 SCAR=0.0
Pod documented
46
47 2583 return scalar @{$self->{_array}};
48 }
49  
50 sub get_highest_number {
51 1280 ▶ my ($self, $do_splice) = @_;
Subroutine get_highest_number: called CC=2 SCAR=6.9
Pod documented
52  
53 1280 my $number;
54 1280 ▶ if ($do_splice) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_splice) { } 1278 2 1280
55 1278 $number = shift(@{$self->{_array}});
56 1278 return $number;
57 } else {
58 2 return $self->{_array}->[0];
59 }
60 }
61  
62 sub get_label {
63 1 ▶ my $self = shift;
Subroutine get_label: called CC=1 SCAR=0.0
Pod documented
64
65 1 return $self->{label};
66 }
67  
68 26 1;
69  
70 __END__
« Build ↑ Summary blib/lib/Games/Bingo/Constants.pm »