Class: Fsrs::CardScheduler

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

Overview

Determines next review date

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card) ⇒ CardScheduler

Returns a new instance of CardScheduler.



68
69
70
71
72
73
# File 'lib/fsrs/fsrs.rb', line 68

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.



66
67
68
# File 'lib/fsrs/fsrs.rb', line 66

def again
  @again
end

#easyObject

Returns the value of attribute easy.



66
67
68
# File 'lib/fsrs/fsrs.rb', line 66

def easy
  @easy
end

#goodObject

Returns the value of attribute good.



66
67
68
# File 'lib/fsrs/fsrs.rb', line 66

def good
  @good
end

#hardObject

Returns the value of attribute hard.



66
67
68
# File 'lib/fsrs/fsrs.rb', line 66

def hard
  @hard
end

Instance Method Details

#record_log(card, now) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/fsrs/fsrs.rb', line 91

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



86
87
88
89
# File 'lib/fsrs/fsrs.rb', line 86

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



75
76
77
78
79
80
81
82
83
84
# File 'lib/fsrs/fsrs.rb', line 75

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