Sha256: 078f1a05de51defa13d81c73d35613e44ca648e460c1fd1fb2216efc89cbc1e0
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module ActiveRecall class SoftLeitnerSystem DELAYS = [3, 7, 14, 30, 60, 120, 240].freeze 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 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 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 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 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 private attr_accessor :box attr_reader :current_time, :times_right, :times_wrong def next_review (current_time + DELAYS[[DELAYS.count, box].min - 1].days) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_recall-1.8.6 | lib/active_recall/algorithms/soft_leitner_system.rb |