active_recall 1.8.5 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e96531570c81f3e7457acc497a7db792708b6b765794e2294b00cce0bd0cfe2
4
- data.tar.gz: 06c2f07e0438fc376beefe980dbdc579f06bb7d8bab77e692faed876b5a69629
3
+ metadata.gz: 95111c003ae9481ad46fd817553888897dcbcab55e901240bb76169dc60c56ff
4
+ data.tar.gz: 71c3da4109511587c2adbc2056d8ddd12f18e5c0bfa263b38c3e1516b667c8a0
5
5
  SHA512:
6
- metadata.gz: c8c4385a5646b277f27b6a90505e6f55847eba3d5e96bb32e0694f9148a018f71846d5cb9d552078a5c215965e5d72f6661f96c64885e9199ff557e77b47b059
7
- data.tar.gz: 9089edaa9ef21c0d1a8750d60b223ac4cda49c075268bee4bea25493b7951c3bd31747a129a93721f0e239efb41bb9d7db3a6f96d157d9b2f95930494f812c91
6
+ metadata.gz: 4a93d9af15d20ecaf631a7ebf9ae36568849c103f916e80b4d4bd0782563420b1280aca3fa951ad622ec30b1e6d6a509966b5ffa92ef940c75928c175a05dd46
7
+ data.tar.gz: dd1119b28d07cf45db8177ffba1b7486e5b623d8472c2f7decb1549391d9258c9924c6b22b5285647b3c1fecc26e1f8cc2980ca73615c9e37356cc22d6b72e37
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+ .idea/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_recall (1.8.5)
4
+ active_recall (1.8.6)
5
5
  activerecord (>= 5.2.3, <= 7.1)
6
6
  activesupport (>= 5.2.3, <= 7.1)
7
7
 
data/README.md CHANGED
@@ -35,6 +35,7 @@ ActiveRecall.configure do |config|
35
35
  config.algorithm_class = ActiveRecall::FibonacciSequence
36
36
  end
37
37
  ```
38
+ Algorithms include `FibonacciSequence`, `LeitnerSystem`, and `SoftLeitnerSystem`.
38
39
  For Rails applications, try doing this from within an [initializer file](https://guides.rubyonrails.org/configuring.html#using-initializer-files).
39
40
 
40
41
  Assume you have an application allowing your users to study words in a foreign language. Using the `has_deck` method you can set up a deck of flashcards that the user will study:
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecall
4
+ class SoftLeitnerSystem
5
+ DELAYS = [3, 7, 14, 30, 60, 120, 240].freeze
6
+
7
+ def self.right(box:, times_right:, times_wrong:, current_time: Time.current)
8
+ new(
9
+ box: box,
10
+ current_time: current_time,
11
+ times_right: times_right,
12
+ times_wrong: times_wrong
13
+ ).right
14
+ end
15
+
16
+ def self.wrong(box:, times_right:, times_wrong:, current_time: Time.current)
17
+ new(
18
+ box: box,
19
+ current_time: current_time,
20
+ times_right: times_right,
21
+ times_wrong: times_wrong
22
+ ).wrong
23
+ end
24
+
25
+ def initialize(box:, times_right:, times_wrong:, current_time: Time.current)
26
+ @box = box
27
+ @current_time = current_time
28
+ @times_right = times_right
29
+ @times_wrong = times_wrong
30
+ end
31
+
32
+ def right
33
+ self.box = [box + 1, DELAYS.count].min
34
+
35
+ {
36
+ box: box,
37
+ times_right: times_right + 1,
38
+ times_wrong: times_wrong,
39
+ last_reviewed: current_time,
40
+ next_review: next_review
41
+ }
42
+ end
43
+
44
+ def wrong
45
+ self.box = [box - 1, 0].max
46
+
47
+ {
48
+ box: box,
49
+ times_right: times_right,
50
+ times_wrong: times_wrong + 1,
51
+ last_reviewed: current_time,
52
+ next_review: next_review
53
+ }
54
+ end
55
+
56
+ private
57
+
58
+ attr_accessor :box
59
+ attr_reader :current_time, :times_right, :times_wrong
60
+
61
+ def next_review
62
+ (current_time + DELAYS[[DELAYS.count, box].min - 1].days)
63
+ end
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecall
4
- VERSION = "1.8.5"
4
+ VERSION = "1.8.6"
5
5
  end
data/lib/active_recall.rb CHANGED
@@ -5,6 +5,7 @@ require "active_recall/deck_methods"
5
5
  require "active_recall/item_methods"
6
6
  require "active_recall/algorithms/fibonacci_sequence"
7
7
  require "active_recall/algorithms/leitner_system"
8
+ require "active_recall/algorithms/soft_leitner_system"
8
9
  require "active_recall/configuration"
9
10
  require "active_recall/models/deck"
10
11
  require "active_recall/models/item"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_recall
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gravina
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-08-06 00:00:00.000000000 Z
12
+ date: 2023-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -130,6 +130,7 @@ files:
130
130
  - lib/active_recall.rb
131
131
  - lib/active_recall/algorithms/fibonacci_sequence.rb
132
132
  - lib/active_recall/algorithms/leitner_system.rb
133
+ - lib/active_recall/algorithms/soft_leitner_system.rb
133
134
  - lib/active_recall/base.rb
134
135
  - lib/active_recall/configuration.rb
135
136
  - lib/active_recall/deck_methods.rb