Class: ActiveRecall::LeitnerSystem
- Inherits:
-
Object
- Object
- ActiveRecall::LeitnerSystem
- Defined in:
- lib/active_recall/algorithms/leitner_system.rb
Constant Summary collapse
- DELAYS =
[3, 7, 14, 30, 60, 120, 240].freeze
Class Method Summary collapse
- .right(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object
- .wrong(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object
Instance Method Summary collapse
-
#initialize(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ LeitnerSystem
constructor
A new instance of LeitnerSystem.
- #right ⇒ Object
- #wrong ⇒ Object
Constructor Details
#initialize(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ LeitnerSystem
Returns a new instance of LeitnerSystem.
25 26 27 28 29 30 |
# File 'lib/active_recall/algorithms/leitner_system.rb', line 25 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
.right(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/active_recall/algorithms/leitner_system.rb', line 7 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 |
.wrong(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/active_recall/algorithms/leitner_system.rb', line 16 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
#right ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/active_recall/algorithms/leitner_system.rb', line 32 def right { box: box + 1, times_right: times_right + 1, times_wrong: times_wrong, last_reviewed: current_time, next_review: next_review } end |
#wrong ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/active_recall/algorithms/leitner_system.rb', line 42 def wrong { box: 0, times_right: times_right, times_wrong: times_wrong + 1, last_reviewed: current_time, next_review: nil } end |