tworgy-spaced-repetition 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,12 +15,14 @@ module SuperMemo
15
15
  self.number_repetitions = 0
16
16
  self.quality_of_last_recall = nil
17
17
  self.repetition_interval = nil
18
- self.next_repetition = Date.today
18
+ self.next_repetition = nil
19
19
  end
20
20
 
21
21
  def process_recall_result(quality_of_recall)
22
22
  DBC.require(quality_of_recall >= 0)
23
23
  DBC.require(quality_of_recall <= 5)
24
+ DBC.require(easiness_factor)
25
+ DBC.require(number_repetitions)
24
26
 
25
27
  if quality_of_recall < 3
26
28
  self.number_repetitions = 0
@@ -43,6 +45,10 @@ module SuperMemo
43
45
  self.next_repetition = Date.today + repetition_interval
44
46
  end
45
47
 
48
+ def scheduled_to_recall?
49
+ !next_repetition.nil? && next_repetition <= Date.today
50
+ end
51
+
46
52
  def check_spaced_repetition_methods
47
53
  begin
48
54
  send(:easiness_factor)
@@ -53,7 +53,7 @@ describe SuperMemo::SM2 do
53
53
  @flash_card.number_repetitions.should == 0
54
54
  @flash_card.repetition_interval.should == nil
55
55
  @flash_card.quality_of_last_recall.should == nil
56
- @flash_card.next_repetition.should == Date.today
56
+ @flash_card.next_repetition.should == nil
57
57
  end
58
58
 
59
59
  it 'should schedule next repetition for tomorrow if repetition_interval = 0 and quality_of_last_recall = 4' do
@@ -75,6 +75,25 @@ describe SuperMemo::SM2 do
75
75
  @flash_card.easiness_factor.should be_close(2.5, 0.01)
76
76
  end
77
77
 
78
+ it 'should report as scheduled to recall (for today)' do
79
+ @flash_card.next_repetition = Date.today
80
+ @flash_card.scheduled_to_recall?.should == true
81
+
82
+ @flash_card.next_repetition = Date.today - 1
83
+ @flash_card.scheduled_to_recall?.should == true
84
+ end
85
+
86
+ it 'should not be scheduled to recall' do
87
+ @flash_card.next_repetition = nil
88
+ @flash_card.scheduled_to_recall?.should == false
89
+
90
+ @flash_card.next_repetition = Date.today + 1
91
+ @flash_card.scheduled_to_recall?.should == false
92
+
93
+ @flash_card.next_repetition = Date.today + 99
94
+ @flash_card.scheduled_to_recall?.should == false
95
+ end
96
+
78
97
  end
79
98
 
80
99
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tworgy-spaced-repetition
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Holroyd