Class: Mangrove::Option::None
- Inherits:
-
Object
- Object
- Mangrove::Option::None
- Extended by:
- T::Generic, T::Helpers, T::Sig
- Includes:
- Mangrove::Option
- Defined in:
- lib/mangrove/option.rb
Overview
Option::None
Constant Summary collapse
- InnerType =
type_member
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #expect!(message) ⇒ InnerType
- #expect_with!(&block) ⇒ InnerType
- #map_none(&block) ⇒ Option[InnerType]
- #map_some(&_block) ⇒ Option::None[InnerType]
- #none? ⇒ Boolean
- #some? ⇒ Boolean
- #transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]
- #unwrap! ⇒ InnerType
- #unwrap_or(default) ⇒ InnerType
Instance Method Details
#==(other) ⇒ Boolean
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/mangrove/option.rb', line 112 def ==(other) case other when Option::Some false when Option::None true else false # T.absurd(other) end end |
#expect!(message) ⇒ InnerType
135 136 137 |
# File 'lib/mangrove/option.rb', line 135 def expect!() raise Option::ControlSignal, end |
#expect_with!(&block) ⇒ InnerType
140 141 142 |
# File 'lib/mangrove/option.rb', line 140 def expect_with!(&block) raise Option::ControlSignal, block.call end |
#map_none(&block) ⇒ Option[InnerType]
156 157 158 |
# File 'lib/mangrove/option.rb', line 156 def map_none(&block) block.call end |
#map_some(&_block) ⇒ Option::None[InnerType]
151 152 153 |
# File 'lib/mangrove/option.rb', line 151 def map_some(&_block) self end |
#none? ⇒ Boolean
148 |
# File 'lib/mangrove/option.rb', line 148 def none? = true |
#some? ⇒ Boolean
145 |
# File 'lib/mangrove/option.rb', line 145 def some? = false |
#transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]
161 162 163 |
# File 'lib/mangrove/option.rb', line 161 def transpose(err) Result::Err.new(err) end |
#unwrap! ⇒ InnerType
130 131 132 |
# File 'lib/mangrove/option.rb', line 130 def unwrap! raise Option::ControlSignal, "called `Option#unwrap!` on an `None` value: #{self}" end |
#unwrap_or(default) ⇒ InnerType
125 126 127 |
# File 'lib/mangrove/option.rb', line 125 def unwrap_or(default) default end |