Class: LabCoat::Result
- Inherits:
-
Object
- Object
- LabCoat::Result
- Defined in:
- lib/lab_coat/result.rb
Overview
The result of a single ‘Experiment` run, that is published by the `Experiment`.
Instance Attribute Summary collapse
-
#candidate ⇒ Object
readonly
Returns the value of attribute candidate.
-
#control ⇒ Object
readonly
Returns the value of attribute control.
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
Instance Method Summary collapse
-
#ignored? ⇒ TrueClass, FalseClass
Whether or not the result should be ignored, as defined by ‘#Experiment#ignore?`.
-
#initialize(experiment, control, candidate) ⇒ Result
constructor
A new instance of Result.
-
#matched? ⇒ TrueClass, FalseClass
Whether or not the control and candidate match, as defined by ‘Experiment#compare`.
-
#to_h ⇒ Hash
A hash representation of this ‘Result`.
Constructor Details
#initialize(experiment, control, candidate) ⇒ Result
Returns a new instance of Result.
8 9 10 11 12 13 14 15 16 |
# File 'lib/lab_coat/result.rb', line 8 def initialize(experiment, control, candidate) @experiment = experiment @control = control @candidate = candidate @matched = experiment.compare(control, candidate) @ignored = experiment.ignore?(control, candidate) freeze end |
Instance Attribute Details
#candidate ⇒ Object (readonly)
Returns the value of attribute candidate.
6 7 8 |
# File 'lib/lab_coat/result.rb', line 6 def candidate @candidate end |
#control ⇒ Object (readonly)
Returns the value of attribute control.
6 7 8 |
# File 'lib/lab_coat/result.rb', line 6 def control @control end |
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
6 7 8 |
# File 'lib/lab_coat/result.rb', line 6 def experiment @experiment end |
Instance Method Details
#ignored? ⇒ TrueClass, FalseClass
Whether or not the result should be ignored, as defined by ‘#Experiment#ignore?`.
26 27 28 |
# File 'lib/lab_coat/result.rb', line 26 def ignored? @ignored end |
#matched? ⇒ TrueClass, FalseClass
Whether or not the control and candidate match, as defined by ‘Experiment#compare`.
20 21 22 |
# File 'lib/lab_coat/result.rb', line 20 def matched? @matched end |
#to_h ⇒ Hash
Returns A hash representation of this ‘Result`. Useful when publishing.
31 32 33 34 35 36 37 38 39 |
# File 'lib/lab_coat/result.rb', line 31 def to_h { experiment: experiment.name, matched: matched?, ignored: ignored?, control: control.to_h, candidate: candidate.to_h } end |