Class: Sm2::Fact
- Inherits:
-
Object
- Object
- Sm2::Fact
- Defined in:
- lib/sm2/fact.rb
Constant Summary collapse
- MAX_GRADE =
5
- D_EF =
D_EF = (0.1 - (MAX_GRADE - grade) * (0.08 + (MAX_GRADE - grade) * 0.02))
{ 5 => 0.1, 4 => 0, 3 => -0.14, 2 => -0.32, 1 => -0.54, 0 => -0.8 }.freeze
Instance Attribute Summary collapse
-
#easiness_factor ⇒ Object
readonly
Returns the value of attribute easiness_factor.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#repetition ⇒ Object
readonly
Returns the value of attribute repetition.
Instance Method Summary collapse
-
#initialize(easiness_factor: nil, repetition: nil, interval: nil) ⇒ Fact
constructor
A new instance of Fact.
- #next_interval(grade) ⇒ Object
Constructor Details
#initialize(easiness_factor: nil, repetition: nil, interval: nil) ⇒ Fact
Returns a new instance of Fact.
16 17 18 19 20 |
# File 'lib/sm2/fact.rb', line 16 def initialize(easiness_factor: nil, repetition: nil, interval: nil) @easiness_factor = easiness_factor || 2.5 @repetition = repetition || 0 @interval = interval end |
Instance Attribute Details
#easiness_factor ⇒ Object (readonly)
Returns the value of attribute easiness_factor.
14 15 16 |
# File 'lib/sm2/fact.rb', line 14 def easiness_factor @easiness_factor end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
14 15 16 |
# File 'lib/sm2/fact.rb', line 14 def interval @interval end |
#repetition ⇒ Object (readonly)
Returns the value of attribute repetition.
14 15 16 |
# File 'lib/sm2/fact.rb', line 14 def repetition @repetition end |
Instance Method Details
#next_interval(grade) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sm2/fact.rb', line 22 def next_interval(grade) grade = MAX_GRADE if grade > MAX_GRADE if grade >= 3 if repetition == 0 @interval = 1 @repetition = 1 elsif repetition == 1 @interval = 6 @repetition = 2 else @interval = (interval * easiness_factor).round @repetition = repetition + 1 end else @repetition = 0 @interval = 1 end @easiness_factor = (easiness_factor + D_EF[grade]).round(2) @easiness_factor = easiness_factor < 1.3 ? 1.3 : easiness_factor return interval end |