Class: TTY::Option::Result
- Inherits:
-
Object
- Object
- TTY::Option::Result
- Defined in:
- lib/tty/option/result.rb
Overview
A monad that respresents success and failure conditions
Defined Under Namespace
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Reason for failure.
-
#value ⇒ Object
readonly
Wrapped value.
Class Method Summary collapse
-
.failure(value) ⇒ Object
Wrap a value in a failure monad.
-
.success(value) ⇒ Object
Wrap a value in a success monad.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Check whether or not a result is a failure class.
-
#success? ⇒ Boolean
Check whether or not a result is a success monad.
Instance Attribute Details
#error ⇒ Object (readonly)
Reason for failure
29 30 31 |
# File 'lib/tty/option/result.rb', line 29 def error @error end |
#value ⇒ Object (readonly)
Wrapped value
24 25 26 |
# File 'lib/tty/option/result.rb', line 24 def value @value end |
Class Method Details
Instance Method Details
#failure? ⇒ Boolean
Check whether or not a result is a failure class
45 46 47 |
# File 'lib/tty/option/result.rb', line 45 def failure? is_a?(Failure) end |
#success? ⇒ Boolean
Check whether or not a result is a success monad
36 37 38 |
# File 'lib/tty/option/result.rb', line 36 def success? is_a?(Success) end |