Class: Differential::Calculator::Totals

Inherits:
Object
  • Object
show all
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

Side::A, Side::B

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTotals

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_sigmaObject (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_sizeObject (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_sigmaObject (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_sizeObject (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

#deltaObject



31
32
33
# File 'lib/differential/calculator/totals.rb', line 31

def delta
  b_sigma - a_sigma
end