Class: Dyph::Outcome::Resolved
- Inherits:
-
Dyph::Outcome
- Object
- Dyph::Outcome
- Dyph::Outcome::Resolved
- Defined in:
- lib/dyph/outcome/resolved.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #apply(fun) ⇒ Object
- #combine(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(result) ⇒ Resolved
constructor
A new instance of Resolved.
- #set_combiner(lambda) ⇒ Object
Methods inherited from Dyph::Outcome
Constructor Details
#initialize(result) ⇒ Resolved
Returns a new instance of Resolved.
4 5 6 7 |
# File 'lib/dyph/outcome/resolved.rb', line 4 def initialize(result) @result = result @combiner = ->(x, y) { x + y } end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/dyph/outcome/resolved.rb', line 3 def result @result end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
13 14 15 16 |
# File 'lib/dyph/outcome/resolved.rb', line 13 def ==(other) self.class == other.class && self.result == other.result end |
#apply(fun) ⇒ Object
29 30 31 |
# File 'lib/dyph/outcome/resolved.rb', line 29 def apply(fun) Outcome::Resolved.new(fun[result]) end |
#combine(other) ⇒ Object
24 25 26 27 |
# File 'lib/dyph/outcome/resolved.rb', line 24 def combine(other) @result = @combiner[@result, other.result] self end |
#hash ⇒ Object
20 21 22 |
# File 'lib/dyph/outcome/resolved.rb', line 20 def hash self.result.hash end |
#set_combiner(lambda) ⇒ Object
9 10 11 |
# File 'lib/dyph/outcome/resolved.rb', line 9 def set_combiner(lambda) @combiner = lambda end |