Class: ActiveRecall::SoftLeitnerSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/active_recall/algorithms/soft_leitner_system.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ SoftLeitnerSystem

Returns a new instance of SoftLeitnerSystem.



31
32
33
34
35
36
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 31

def initialize(box:, times_right:, times_wrong:, current_time: Time.current)
  @box = box
  @current_time = current_time
  @times_right = times_right
  @times_wrong = times_wrong
end

Class Method Details

.required_attributesObject



5
6
7
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 5

def self.required_attributes
  REQUIRED_ATTRIBUTES
end

.right(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 9

def self.right(box:, times_right:, times_wrong:, current_time: Time.current)
  new(
    box: box,
    current_time: current_time,
    times_right: times_right,
    times_wrong: times_wrong
  ).right
end

.typeObject



18
19
20
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 18

def self.type
  :binary
end

.wrong(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 22

def self.wrong(box:, times_right:, times_wrong:, current_time: Time.current)
  new(
    box: box,
    current_time: current_time,
    times_right: times_right,
    times_wrong: times_wrong
  ).wrong
end

Instance Method Details

#rightObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 38

def right
  self.box = [box + 1, DELAYS.count].min

  {
    box: box,
    times_right: times_right + 1,
    times_wrong: times_wrong,
    last_reviewed: current_time,
    next_review: next_review
  }
end

#wrongObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/active_recall/algorithms/soft_leitner_system.rb', line 50

def wrong
  self.box = [box - 1, 0].max

  {
    box: box,
    times_right: times_right,
    times_wrong: times_wrong + 1,
    last_reviewed: current_time,
    next_review: next_review
  }
end