Class: ActiveRecall::LeitnerSystem

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LeitnerSystem.



31
32
33
34
35
36
# File 'lib/active_recall/algorithms/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/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/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/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/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
# File 'lib/active_recall/algorithms/leitner_system.rb', line 38

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

#wrongObject



48
49
50
51
52
53
54
55
56
# File 'lib/active_recall/algorithms/leitner_system.rb', line 48

def wrong
  {
    box: 0,
    times_right: times_right,
    times_wrong: times_wrong + 1,
    last_reviewed: current_time,
    next_review: nil
  }
end