Class: Differential::Calculator::Totals
- Inherits:
-
Object
- Object
- Differential::Calculator::Totals
- Includes:
- Side
- Defined in:
- lib/differential/calculator/totals.rb
Overview
Value object that can capture basic calculations:
-
a_sigma is the sum of data set A’s values.
-
b_sigma is the sum of data set B’s values.
-
delta is the difference: b_sigma - a_sigma.
Constant Summary
Constants included from Side
Instance Attribute Summary collapse
-
#a_sigma ⇒ Object
readonly
Returns the value of attribute a_sigma.
-
#a_size ⇒ Object
readonly
Returns the value of attribute a_size.
-
#b_sigma ⇒ Object
readonly
Returns the value of attribute b_sigma.
-
#b_size ⇒ Object
readonly
Returns the value of attribute b_size.
Instance Method Summary collapse
- #add(value, side) ⇒ Object
- #delta ⇒ Object
-
#initialize ⇒ Totals
constructor
A new instance of Totals.
Constructor Details
#initialize ⇒ Totals
Returns a new instance of Totals.
24 25 26 27 28 29 |
# File 'lib/differential/calculator/totals.rb', line 24 def initialize @a_sigma = 0 @a_size = 0 @b_sigma = 0 @b_size = 0 end |
Instance Attribute Details
#a_sigma ⇒ Object (readonly)
Returns the value of attribute a_sigma.
19 20 21 |
# File 'lib/differential/calculator/totals.rb', line 19 def a_sigma @a_sigma end |
#a_size ⇒ Object (readonly)
Returns the value of attribute a_size.
19 20 21 |
# File 'lib/differential/calculator/totals.rb', line 19 def a_size @a_size end |
#b_sigma ⇒ Object (readonly)
Returns the value of attribute b_sigma.
19 20 21 |
# File 'lib/differential/calculator/totals.rb', line 19 def b_sigma @b_sigma end |
#b_size ⇒ Object (readonly)
Returns the value of attribute b_size.
19 20 21 |
# File 'lib/differential/calculator/totals.rb', line 19 def b_size @b_size end |
Instance Method Details
#add(value, side) ⇒ Object
35 36 37 38 |
# File 'lib/differential/calculator/totals.rb', line 35 def add(value, side) increment_sigma(value, side) increment_size(side) end |
#delta ⇒ Object
31 32 33 |
# File 'lib/differential/calculator/totals.rb', line 31 def delta b_sigma - a_sigma end |