Plucene/Search/PhrasePositions.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 92.4% 49 / 53 CC 6 SCAR 8.6
CC
6
Cov
95%
new
4.1
next
2.0
next_position
2.0
CRAP 2.4
« Plucene/Document/DateSerializer.pm ↑ Summary Plucene/Search/TermScorer.pm »
1 package Plucene::Search::PhrasePositions;
2  
3 =head1 NAME
4  
5 Plucene::Search::PhrasePositions - The position of a phrase
6  
7 =head1 SYNOPSIS
8  
9 my $phpos = Plucene::Search::PhrasePositions->new;
10  
11 my $next = $phpos->next;
12 my $first_pos = $phpos->first_position;
13 my $next_pos = $phpos->next_position;
14
15 =head1 DESCRIPTION
16  
17 =head1 METHODS
18  
19 =cut
20  
21 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 ▶use base 'Class::Accessor::Fast';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 __PACKAGE__->mk_accessors(qw/ doc position count offset tp next_in_list /);
27  
28 =head2 new
29  
30 my $phpos = Plucene::Search::PhrasePositions->new;
31  
32 Make a new Plucene::Search::PhrasePositions object.
33
34 =head2 doc / position / count / offset / tp / next
35  
36 Get / set these attibutes.
37  
38 =cut
39  
40 15 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
41 15 my $self = shift->SUPER::new(@_);
42 15 ▶ $self->{offset} ||= 0;
Condition100%2/2
$self->{"offset"} ||= 0
l!l
87
MC/DC100%1/1
$self->{"offset"} ||= 0
$self->{"offset"}
Truth table100%2/2
A
A= $self->{"offset"}
Aresult
11
00
43 15 ▶ $self->{position} ||= 0;
Condition50%1/2
$self->{"position"} ||= 0
l!l
015
MC/DC0%0/1
$self->{"position"} ||= 0
$self->{"position"}
Truth table50%1/2
A
A= $self->{"position"}
Aresult
11
00
44 15 ▶ $self->{count} ||= 0;
Condition50%1/2
$self->{"count"} ||= 0
l!l
015
MC/DC0%0/1
$self->{"count"} ||= 0
$self->{"count"}
Truth table50%1/2
A
A= $self->{"count"}
Aresult
11
00
45 15 $self->next;
46 15 $self;
47 }
48  
49 =head2 next
50  
51 my $next = $phpos->next;
52  
53 =cut
54  
55 194 ▶sub next {
Subroutine next: called CC=2 SCAR=6.9
Pod documented
56 194 my $self = shift;
57 194 ▶ if (!$self->{tp}->next) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tp"}->next) 7 187 194
58 7 $self->doc(~0);
59 7 return;
60 }
61 187 $self->doc($self->tp->doc);
62 187 $self->position(0);
63 }
64  
65 =head2 first_position
66  
67 my $first = $phpos->first_position;
68  
69 =cut
70  
71 173 ▶sub first_position {
Subroutine first_position: called CC=1 SCAR=0.0
Pod documented
72 173 my $self = shift;
73 173 $self->count($self->tp->freq);
74 173 $self->next_position;
75 }
76  
77 =head2 next_position
78  
79 my $next_pos = $phpos->next_position;
80  
81 =cut
82  
83 725 ▶sub next_position {
Subroutine next_position: called CC=2 SCAR=6.9
Pod documented
84 725 my $self = shift;
85 725 ▶ return unless $self->{count}-- > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"count"}-- > 0 83 642 725
86 642 $self->position($self->tp->next_position - $self->offset);
87 }
88  
89 4 1;
« Plucene/Document/DateSerializer.pm ↑ Summary Plucene/Search/TermScorer.pm »