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(&_block) ⇒ Option[T.type_parameter(:NewInnerType)]
- #none? ⇒ Boolean
- #or(default) ⇒ Option[InnerType]
- #some? ⇒ Boolean
- #transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]
- #unwrap! ⇒ InnerType
- #unwrap_or(default) ⇒ InnerType
Methods included from Mangrove::Option
Instance Method Details
#==(other) ⇒ Boolean
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/mangrove/option.rb', line 126 def ==(other) case other when Option::Some false when Option::None true else false # T.absurd(other) end end |
#expect!(message) ⇒ InnerType
149 150 151 |
# File 'lib/mangrove/option.rb', line 149 def expect!() raise Option::ControlSignal, end |
#expect_with!(&block) ⇒ InnerType
154 155 156 |
# File 'lib/mangrove/option.rb', line 154 def expect_with!(&block) raise Option::ControlSignal, block.call end |
#map(&_block) ⇒ Option[T.type_parameter(:NewInnerType)]
165 166 167 |
# File 'lib/mangrove/option.rb', line 165 def map(&_block) T.cast(self, Option[T.type_parameter(:NewInnerType)]) end |
#none? ⇒ Boolean
162 |
# File 'lib/mangrove/option.rb', line 162 def none? = true |
#or(default) ⇒ Option[InnerType]
170 171 172 |
# File 'lib/mangrove/option.rb', line 170 def or(default) default end |
#some? ⇒ Boolean
159 |
# File 'lib/mangrove/option.rb', line 159 def some? = false |
#transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]
175 176 177 |
# File 'lib/mangrove/option.rb', line 175 def transpose(err) Result::Err.new(err) end |
#unwrap! ⇒ InnerType
144 145 146 |
# File 'lib/mangrove/option.rb', line 144 def unwrap! raise Option::ControlSignal, "called `Option#unwrap!` on an `None` value: #{self}" end |
#unwrap_or(default) ⇒ InnerType
139 140 141 |
# File 'lib/mangrove/option.rb', line 139 def unwrap_or(default) default end |