blib/lib/HTML/ListScraper/Occurence.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 7 totaltotal 83.0% 44 / 53 CC 3 SCAR 4.4
CC
3
Cov
95%
append_pos
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« blib/lib/HTML/ListScraper/Vat.pm ↑ Summary blib/lib/HTML/ListScraper/Dust.pm »
1 package HTML::ListScraper::Occurence;
2  
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 84193 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 84193 my ($class, $length, $pos) = @_;
8 84193 my $self = { length => $length, spread => 1,
9 edge => $pos, positions => [ $pos ] };
10 84193 bless $self, $class;
11  
12 84193 return $self;
13 }
14  
15 102664 ▶sub spread {
Subroutine spread: called CC=1 SCAR=0.0
Pod undocumented
16 102664 my $self = shift;
17  
18 102664 return $self->{spread};
19 }
20  
21 2869 ▶sub len {
Subroutine len: called CC=1 SCAR=0.0
Pod undocumented
22 2869 my $self = shift;
23  
24 2869 return $self->{length};
25 }
26  
27 2854 ▶sub first_pos {
Subroutine first_pos: called CC=1 SCAR=0.0
Pod undocumented
28 2854 my $self = shift;
29  
30 2854 return $self->{positions}->[0];
31 }
32  
33 3915 ▶sub log_score {
Subroutine log_score: called CC=1 SCAR=0.0
Pod undocumented
34 3915 my $self = shift;
35  
36 # return log($self->{spread}) * $self->{length};
37 3915 return log($self->{spread}) * log($self->{length});
38 }
39  
40 80120 ▶sub positions {
Subroutine positions: called CC=1 SCAR=0.0
Pod undocumented
41 80120 my $self = shift;
42  
43 80120 return @{$self->{positions}};
44 }
45  
46 318147 ▶sub append_pos {
Subroutine append_pos: called CC=3 SCAR=11.1
Pod undocumented
47 318147 my ($self, $pos) = @_;
48  
49 318147 my $count = scalar(@{$self->{positions}});
50 318147 ▶ if ($pos <= $self->{positions}->[$count - 1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos <= $self->{"positions"}[$count - 1]) 0 318147 318147
51 0 die "position $pos out of order";
52 }
53  
54 318147 push @{$self->{positions}}, $pos;
55  
56 318147 ▶ if ($self->{edge} + $self->{length} <= $pos) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"edge"} + $self->{"length"} <= $pos) 190840 127307 318147
57 190840 ++($self->{spread});
58 190840 $self->{edge} = $pos;
59 }
60  
61 318147 return $self->{spread};
62 }
63  
64 10 1;
« blib/lib/HTML/ListScraper/Vat.pm ↑ Summary blib/lib/HTML/ListScraper/Dust.pm »