Class: ActiveRecall::FSRS::Internal::CardScheduler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card) ⇒ CardScheduler

Returns a new instance of CardScheduler.



96
97
98
99
100
101
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 96

def initialize(card)
  @again = card.clone
  @hard = card.clone
  @good = card.clone
  @easy = card.clone
end

Instance Attribute Details

#againObject

Returns the value of attribute again.



94
95
96
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 94

def again
  @again
end

#easyObject

Returns the value of attribute easy.



94
95
96
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 94

def easy
  @easy
end

#goodObject

Returns the value of attribute good.



94
95
96
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 94

def good
  @good
end

#hardObject

Returns the value of attribute hard.



94
95
96
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 94

def hard
  @hard
end

Instance Method Details

#record_log(card, now) ⇒ Object



119
120
121
122
123
124
125
126
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 119

def record_log(card, now)
  {
    Rating::AGAIN => record_again_log(card, now),
    Rating::HARD => record_hard_log(card, now),
    Rating::GOOD => record_good_log(card, now),
    Rating::EASY => record_easy_log(card, now)
  }
end

#schedule(now, hard_interval, good_interval, easy_interval) ⇒ Object



114
115
116
117
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 114

def schedule(now, hard_interval, good_interval, easy_interval)
  update_schedule_days(hard_interval, good_interval, easy_interval)
  update_due_dates(now, hard_interval, good_interval, easy_interval)
end

#update_state(state) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 103

def update_state(state)
  case state
  when State::NEW
    update_new_state
  when State::LEARNING, State::RELEARNING
    update_learning_relearning_state(state)
  when State::REVIEW
    update_review_state
  end
end