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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/active_recall/algorithms/soft_leitner_system.rb +65 -0
- data/lib/active_recall/version.rb +1 -1
- data/lib/active_recall.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95111c003ae9481ad46fd817553888897dcbcab55e901240bb76169dc60c56ff
|
4
|
+
data.tar.gz: 71c3da4109511587c2adbc2056d8ddd12f18e5c0bfa263b38c3e1516b667c8a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a93d9af15d20ecaf631a7ebf9ae36568849c103f916e80b4d4bd0782563420b1280aca3fa951ad622ec30b1e6d6a509966b5ffa92ef940c75928c175a05dd46
|
7
|
+
data.tar.gz: dd1119b28d07cf45db8177ffba1b7486e5b623d8472c2f7decb1549391d9258c9924c6b22b5285647b3c1fecc26e1f8cc2980ca73615c9e37356cc22d6b72e37
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
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
|
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.
|
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-
|
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
|