blib/lib/Repetition/Interval.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 100% 43 / 43 CC 2 SCAR 1.7
CC
2
Cov
100%
calculate_new_mean
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Repetition::Interval;
2 2 $Repetition::Interval::VERSION = '0.001';
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Types::Standard qw(Num Int);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use POSIX qw(round);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: A library to calculate intervals for spaced repetition memorization
10  
11  
12 has default_avg_grade => (
13 is => 'ro',
14 isa => Num,
15 2 ▶ default => sub { 2.5; }
Subroutine __ANON__: called CC=1 SCAR=0.0
16 2 );
17  
18 has priority => (
19 is => 'ro',
20 isa => Int,
21 2 ▶ default => sub { 4; }
Subroutine __ANON__: called CC=1 SCAR=0.0
22 2 );
23  
24  
25 11 ▶sub calculate_new_mean {
Subroutine calculate_new_mean: called CC=2 SCAR=6.9
Pod documented
26 11 my ($self, $current_grade, $review_cnt, $prev_mean) = @_;
27  
28 11 ▶ return ($self->default_avg_grade() + $current_grade) / 2 if $review_cnt == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $review_cnt == 1 2 9 11
29  
30 9 return (($prev_mean*$review_cnt)/($review_cnt + 1)) + ($current_grade / ($review_cnt + 1));
31 }
32  
33  
34 12 ▶sub schedule_next_review {
Subroutine schedule_next_review: called CC=1 SCAR=0.0
Pod documented
35 12 my ($self, $current_grade, $review_cnt, $mean_of_grades) = @_;
36  
37 12 return round(1 + exp($current_grade - $self->priority())*$review_cnt**($mean_of_grades/2));
38 }
39  
40  
41 1 ▶sub schedule_next_review_seconds {
Subroutine schedule_next_review_seconds: called CC=1 SCAR=0.0
Pod documented
42 1 my $self = shift;
43 1 return ($self->schedule_next_review(@_))*86_400;
44 }
45  
46 2 1;
47  
48 __END__
↑ Summary