Class: ActiveRecall::Item
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveRecall::Item
- Defined in:
- lib/active_recall/models/item.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.expired(current_time: Time.current) ⇒ Object
12 13 14 |
# File 'lib/active_recall/models/item.rb', line 12 def self.expired(current_time: Time.current) where(["box > ? and next_review <= ?", 0, current_time]) end |
.known(current_time: Time.current) ⇒ Object
16 17 18 |
# File 'lib/active_recall/models/item.rb', line 16 def self.known(current_time: Time.current) where(["box > ? and next_review > ?", 0, current_time]) end |
Instance Method Details
#right! ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/active_recall/models/item.rb', line 34 def right! if algorithm_class.type == :binary update!(algorithm_class.right(**scoring_attributes)) else raise IncompatibleAlgorithmError, "#{algorithm_class.name} is not a binary algorithm, so is not compatible with the #right! method" end end |
#score!(grade) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/active_recall/models/item.rb', line 20 def score!(grade) if algorithm_class.type == :gradable update!( algorithm_class.score(**scoring_attributes.merge(grade: grade)) ) else raise IncompatibleAlgorithmError, "#{algorithm_class.name} is a not an gradable algorithm, so is not compatible with the #score! method" end end |
#source ⇒ Object
30 31 32 |
# File 'lib/active_recall/models/item.rb', line 30 def source source_type.constantize.find(source_id) end |
#wrong! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/active_recall/models/item.rb', line 42 def wrong! if algorithm_class.type == :binary update!(algorithm_class.wrong(**scoring_attributes)) else raise IncompatibleAlgorithmError, "#{algorithm_class.name} is not a binary algorithm, so is not compatible with the #wrong! method" end end |