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 CC 4 SCAR 3.4
CC
4
Cov
100%
new
2.0
get_random_number
2.0
get_highest_number
2.0
CRAP 1.4
« lib/Games/Bingo.pm ↑ Summary lib/Games/Bingo/Constants.pm »
1 package Games::Bingo::Column;
2  
3 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 27 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 27 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 27 ▶use Games::Bingo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 27 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 27 @ISA = qw(Games::Bingo);
10 27 $VERSION = '0.18';
11  
12 2664 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
13 2664 my $class = shift;
14 2664 my $label = shift;
15 2664 my @array = sort _reverse (@_);
16
17 2664 ▶ my $self = bless {
Branch: 1 branch
BranchTrueFalseTotal
$label ? : 2361 303 2664
18 label => $label?$label:0,
19 _array => \@array
20 }, $class;
21 }
22  
23 20917 ▶sub _reverse { $b <=> $a }
Subroutine _reverse: called CC=1 SCAR=0.0
24  
25 2200 ▶sub populate {
Subroutine populate: called CC=1 SCAR=0.0
Pod documented
26 2200 my ($self, $value) = @_;
27
28 2200 push @{$self->{_array}}, $value;
29
30 2200 @{$self->{_array}} = sort _reverse @{$self->{_array}};
31 }
32  
33 2207 ▶sub get_random_number {
Subroutine get_random_number: called CC=2 SCAR=6.9
Pod documented
34 2207 my ($self, $do_splice) = @_;
35
36 2207 my $pos = $self->random($self->count_numbers);
37
38 2207 my $number = $self->{_array}->[$pos];
39 2207 ▶ splice(@{$self->{_array}}, $pos, 1) if $do_splice;
Branch: 1 branch
BranchTrueFalseTotal
if $do_splice 2206 1 2207
40
41 2207 return $number;
42 }
43  
44 4383 ▶sub count_numbers {
Subroutine count_numbers: called CC=1 SCAR=0.0
Pod documented
45 4383 my $self = shift;
46
47 4383 return scalar @{$self->{_array}};
48 }
49  
50 2180 ▶sub get_highest_number {
Subroutine get_highest_number: called CC=2 SCAR=6.9
Pod documented
51 2180 my ($self, $do_splice) = @_;
52  
53 2180 my $number;
54 2180 ▶ if ($do_splice) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_splice) { } 2178 2 2180
55 2178 $number = shift(@{$self->{_array}});
56 2178 return $number;
57 } else {
58 2 return $self->{_array}->[0];
59 }
60 }
61  
62 1 ▶sub get_label {
Subroutine get_label: called CC=1 SCAR=0.0
Pod documented
63 1 my $self = shift;
64
65 1 return $self->{label};
66 }
67  
68 27 1;
69  
70 __END__
« lib/Games/Bingo.pm ↑ Summary lib/Games/Bingo/Constants.pm »