Class: Course::Result
- Inherits:
-
Object
- Object
- Course::Result
- Defined in:
- lib/course/result.rb
Instance Attribute Summary collapse
-
#failure ⇒ Object
readonly
Returns the value of attribute failure.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(output: nil, failure: nil) ⇒ Result
constructor
A new instance of Result.
- #on_fail {|failure| ... } ⇒ Object
- #on_success {|output| ... } ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(output: nil, failure: nil) ⇒ Result
Returns a new instance of Result.
7 8 9 10 |
# File 'lib/course/result.rb', line 7 def initialize(output: nil, failure: nil) @output = output @failure = failure end |
Instance Attribute Details
#failure ⇒ Object (readonly)
Returns the value of attribute failure.
5 6 7 |
# File 'lib/course/result.rb', line 5 def failure @failure end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
5 6 7 |
# File 'lib/course/result.rb', line 5 def output @output end |
Instance Method Details
#failure? ⇒ Boolean
12 13 14 |
# File 'lib/course/result.rb', line 12 def failure? !success? end |
#on_fail {|failure| ... } ⇒ Object
16 17 18 |
# File 'lib/course/result.rb', line 16 def on_fail yield failure if block_given? && failure? end |
#on_success {|output| ... } ⇒ Object
24 25 26 |
# File 'lib/course/result.rb', line 24 def on_success yield output if block_given? && success? end |
#success? ⇒ Boolean
20 21 22 |
# File 'lib/course/result.rb', line 20 def success? failure.nil? end |