Class: Igniter::Extensions::Contracts::Differential::Divergence
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Differential::Divergence
- Defined in:
- lib/igniter/extensions/contracts/differential/divergence.rb
Instance Attribute Summary collapse
-
#candidate_value ⇒ Object
readonly
Returns the value of attribute candidate_value.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#output_name ⇒ Object
readonly
Returns the value of attribute output_name.
-
#primary_value ⇒ Object
readonly
Returns the value of attribute primary_value.
Instance Method Summary collapse
- #delta ⇒ Object
-
#initialize(output_name:, primary_value:, candidate_value:, kind:) ⇒ Divergence
constructor
A new instance of Divergence.
- #to_h ⇒ Object
Constructor Details
#initialize(output_name:, primary_value:, candidate_value:, kind:) ⇒ Divergence
Returns a new instance of Divergence.
10 11 12 13 14 15 16 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 10 def initialize(output_name:, primary_value:, candidate_value:, kind:) @output_name = output_name.to_sym @primary_value = primary_value @candidate_value = candidate_value @kind = kind.to_sym freeze end |
Instance Attribute Details
#candidate_value ⇒ Object (readonly)
Returns the value of attribute candidate_value.
8 9 10 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 8 def candidate_value @candidate_value end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
8 9 10 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 8 def kind @kind end |
#output_name ⇒ Object (readonly)
Returns the value of attribute output_name.
8 9 10 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 8 def output_name @output_name end |
#primary_value ⇒ Object (readonly)
Returns the value of attribute primary_value.
8 9 10 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 8 def primary_value @primary_value end |
Instance Method Details
#delta ⇒ Object
18 19 20 21 22 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 18 def delta return nil unless primary_value.is_a?(Numeric) && candidate_value.is_a?(Numeric) candidate_value - primary_value end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/igniter/extensions/contracts/differential/divergence.rb', line 24 def to_h { output_name: output_name, primary_value: primary_value, candidate_value: candidate_value, kind: kind, delta: delta } end |