Class: Emu::Ok
- Inherits:
-
Object
- Object
- Emu::Ok
- Defined in:
- lib/emu/result.rb
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(value) ⇒ Ok
constructor
A new instance of Ok.
- #then {|@value| ... } ⇒ Object
- #to_s ⇒ Object
- #unwrap ⇒ Object
- #unwrap_err ⇒ Object
Constructor Details
#initialize(value) ⇒ Ok
Returns a new instance of Ok.
29 30 31 |
# File 'lib/emu/result.rb', line 29 def initialize(value) @value = value end |
Instance Method Details
#error? ⇒ Boolean
49 50 51 |
# File 'lib/emu/result.rb', line 49 def error? false end |
#then {|@value| ... } ⇒ Object
37 38 39 |
# File 'lib/emu/result.rb', line 37 def then yield @value end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/emu/result.rb', line 33 def to_s "Ok(#{@value})" end |
#unwrap ⇒ Object
41 42 43 |
# File 'lib/emu/result.rb', line 41 def unwrap @value end |
#unwrap_err ⇒ Object
45 46 47 |
# File 'lib/emu/result.rb', line 45 def unwrap_err raise "can't unwrap_err Ok(#{@value.inspect})" end |