Class: ActiveRecall::FSRS::Internal::Card

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCard

Returns a new instance of Card.



67
68
69
70
71
72
73
74
75
76
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 67

def initialize
  @due = DateTime.new
  @stability = 0.0
  @difficulty = 0.0
  @elapsed_days = 0
  @scheduled_days = 0
  @reps = 0
  @lapses = 0
  @state = State::NEW
end

Instance Attribute Details

#difficultyObject

Returns the value of attribute difficulty.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def difficulty
  @difficulty
end

#dueObject

Returns the value of attribute due.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def due
  @due
end

#elapsed_daysObject

Returns the value of attribute elapsed_days.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def elapsed_days
  @elapsed_days
end

#lapsesObject

Returns the value of attribute lapses.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def lapses
  @lapses
end

#last_reviewObject

Returns the value of attribute last_review.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def last_review
  @last_review
end

#repsObject

Returns the value of attribute reps.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def reps
  @reps
end

#scheduled_daysObject

Returns the value of attribute scheduled_days.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def scheduled_days
  @scheduled_days
end

#stabilityObject

Returns the value of attribute stability.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def stability
  @stability
end

#stateObject

Returns the value of attribute state.



64
65
66
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 64

def state
  @state
end

Instance Method Details

#deep_cloneObject



88
89
90
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 88

def deep_clone
  Marshal.load(Marshal.dump(self))
end

#get_retrievability(now) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/active_recall/algorithms/fsrs/internal.rb', line 78

def get_retrievability(now)
  decay = -0.5
  factor = (0.9**(1 / decay)) - 1

  return nil unless @state == State::REVIEW

  elapsed_days = [0, (now - @last_review).to_i].max
  (1 + (factor * elapsed_days / @stability))**decay
end