Class: LabCoat::Result

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

Instance Method Summary collapse

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

#candidateObject (readonly)

Returns the value of attribute candidate.



6
7
8
# File 'lib/lab_coat/result.rb', line 6

def candidate
  @candidate
end

#controlObject (readonly)

Returns the value of attribute control.



6
7
8
# File 'lib/lab_coat/result.rb', line 6

def control
  @control
end

#experimentObject (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?`.

Returns:

  • (TrueClass, FalseClass)


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`.

Returns:

  • (TrueClass, FalseClass)


20
21
22
# File 'lib/lab_coat/result.rb', line 20

def matched?
  @matched
end

#to_hHash

Returns A hash representation of this ‘Result`. Useful when publishing.

Returns:

  • (Hash)

    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