Class: Analytic::Stat
- Inherits:
-
Object
- Object
- Analytic::Stat
- Defined in:
- app/models/analytic/stat.rb
Instance Method Summary collapse
- #count ⇒ Integer
-
#delta ⇒ Float?
e.g.
-
#initialize(current:, prior:, name:) ⇒ Stat
constructor
A new instance of Stat.
Constructor Details
#initialize(current:, prior:, name:) ⇒ Stat
Returns a new instance of Stat.
8 9 10 11 12 |
# File 'app/models/analytic/stat.rb', line 8 def initialize(current:, prior:, name:) @current = current @prior = prior @name = name end |
Instance Method Details
#count ⇒ Integer
15 16 17 |
# File 'app/models/analytic/stat.rb', line 15 def count @current end |
#delta ⇒ Float?
e.g. prior = 4 / current = 5 / delta = + 0.25 e.g. prior = 4 / current = 3 / delta = - 0.25
23 24 25 26 27 28 |
# File 'app/models/analytic/stat.rb', line 23 def delta return if @prior.nil? return if @prior.zero? (@current - @prior).fdiv(@prior) end |