Class: Dat::Science::Result
- Inherits:
-
Object
- Object
- Dat::Science::Result
- Defined in:
- lib/dat/science/result.rb
Overview
Internal. The output of running of an observed behavior.
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(experiment, value, duration, exception) ⇒ Result
constructor
A new instance of Result.
- #payload ⇒ Object
- #raised? ⇒ Boolean
Constructor Details
#initialize(experiment, value, duration, exception) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 16 |
# File 'lib/dat/science/result.rb', line 11 def initialize(experiment, value, duration, exception) @duration = duration @exception = exception @experiment = experiment @value = value end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/dat/science/result.rb', line 6 def duration @duration end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
7 8 9 |
# File 'lib/dat/science/result.rb', line 7 def exception @exception end |
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
8 9 10 |
# File 'lib/dat/science/result.rb', line 8 def experiment @experiment end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/dat/science/result.rb', line 9 def value @value end |
Instance Method Details
#==(other) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dat/science/result.rb', line 18 def ==(other) return false unless other.is_a? Dat::Science::Result values_are_equal = experiment.compare(other.value, value) both_raised = other.raised? && raised? neither_raised = !other.raised? && !raised? exceptions_are_equivalent = both_raised && other.exception.class == self.exception.class && other.exception. == self.exception. (values_are_equal && neither_raised) || (both_raised && exceptions_are_equivalent) end |
#hash ⇒ Object
33 34 35 |
# File 'lib/dat/science/result.rb', line 33 def hash exception ^ value end |
#payload ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/dat/science/result.rb', line 37 def payload { :duration => duration, :exception => exception, :value => experiment.clean(value) } end |
#raised? ⇒ Boolean
45 46 47 |
# File 'lib/dat/science/result.rb', line 45 def raised? !!exception end |