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
- #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
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/mangrove/option.rb', line 107 def ==(other) case other when Option::Some false when Option::None true else false # T.absurd(other) end end |
#expect!(message) ⇒ InnerType
130 131 132 |
# File 'lib/mangrove/option.rb', line 130 def expect!() raise Option::ControlSignal, Result::Err.new() end |
#map_none(&block) ⇒ Option[InnerType]
146 147 148 |
# File 'lib/mangrove/option.rb', line 146 def map_none(&block) block.call end |
#map_some(&_block) ⇒ Option::None[InnerType]
141 142 143 |
# File 'lib/mangrove/option.rb', line 141 def map_some(&_block) self end |
#none? ⇒ Boolean
138 |
# File 'lib/mangrove/option.rb', line 138 def none? = true |
#some? ⇒ Boolean
135 |
# File 'lib/mangrove/option.rb', line 135 def some? = false |
#transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]
151 152 153 |
# File 'lib/mangrove/option.rb', line 151 def transpose(err) Result::Err.new(err) end |
#unwrap! ⇒ InnerType
125 126 127 |
# File 'lib/mangrove/option.rb', line 125 def unwrap! raise Option::ControlSignal, Result::Err.new("called `Option#unwrap!` on an `None` value: #{self}") end |
#unwrap_or(default) ⇒ InnerType
120 121 122 |
# File 'lib/mangrove/option.rb', line 120 def unwrap_or(default) default end |