Class: ActiveRecall::SoftLeitnerSystem
- Inherits:
-
Object
- Object
- ActiveRecall::SoftLeitnerSystem
- Defined in:
- lib/active_recall/algorithms/soft_leitner_system.rb
Class Method Summary collapse
- .required_attributes ⇒ Object
- .right(box:, times_right:, times_wrong:, current_time: Time.current) ⇒ Object
- .type ⇒ 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) ⇒ SoftLeitnerSystem
constructor
A new instance of SoftLeitnerSystem.
- #right ⇒ Object
- #wrong ⇒ Object
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_attributes ⇒ Object
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 |
.type ⇒ Object
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
#right ⇒ Object
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 |
#wrong ⇒ Object
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 |