Class: Mangrove::Result::Err
- Inherits:
-
Object
- Object
- Mangrove::Result::Err
- Extended by:
- T::Generic, T::Helpers, T::Sig
- Includes:
- Mangrove::Result
- Defined in:
- lib/mangrove/result.rb
Constant Summary collapse
- OkType =
type_member
- ErrType =
type_member
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #err? ⇒ Boolean
- #err_inner ⇒ ErrType
- #expect!(message) ⇒ OkType
- #expect_with!(&block) ⇒ OkType
- #initialize(inner) ⇒ void constructor
- #map_err(&block) ⇒ Result[OkType, ErrType]
- #map_ok(&_block) ⇒ Result[OkType, ErrType]
- #ok? ⇒ Boolean
- #to_s ⇒ String
- #unwrap! ⇒ OkType
Methods included from Mangrove::Result
Constructor Details
#initialize(inner) ⇒ void
146 147 148 |
# File 'lib/mangrove/result.rb', line 146 def initialize(inner) @inner = inner end |
Instance Method Details
#==(other) ⇒ Boolean
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/mangrove/result.rb', line 151 def ==(other) case other when Result::Ok false when Result::Err other.instance_variable_get(:@inner) == @inner else false end end |
#err? ⇒ Boolean
186 |
# File 'lib/mangrove/result.rb', line 186 def err? = true |
#expect!(message) ⇒ OkType
173 174 175 |
# File 'lib/mangrove/result.rb', line 173 def expect!() raise Result::ControlSignal, end |
#expect_with!(&block) ⇒ OkType
178 179 180 |
# File 'lib/mangrove/result.rb', line 178 def expect_with!(&block) raise Result::ControlSignal, block.call end |
#map_err(&block) ⇒ Result[OkType, ErrType]
194 195 196 |
# File 'lib/mangrove/result.rb', line 194 def map_err(&block) block.call(@inner) end |
#map_ok(&_block) ⇒ Result[OkType, ErrType]
189 190 191 |
# File 'lib/mangrove/result.rb', line 189 def map_ok(&_block) self end |
#ok? ⇒ Boolean
183 |
# File 'lib/mangrove/result.rb', line 183 def ok? = false |
#to_s ⇒ String
199 200 201 |
# File 'lib/mangrove/result.rb', line 199 def to_s "#{super}: inner=`#{@inner}`" end |
#unwrap! ⇒ OkType
168 169 170 |
# File 'lib/mangrove/result.rb', line 168 def unwrap! raise Result::ControlSignal, @inner end |