Class: Mangrove::Option::None

Inherits:
Object
  • Object
show all
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

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (BasicObject)

Returns:

  • (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

Parameters:

  • message (String)

Returns:

Raises:



135
136
137
# File 'lib/mangrove/option.rb', line 135

def expect!(message)
  raise Option::ControlSignal, message
end

#expect_with!(&block) ⇒ InnerType

Parameters:

  • block (T.proc.returns(T.untyped))

Returns:

Raises:



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]

Parameters:

Returns:



156
157
158
# File 'lib/mangrove/option.rb', line 156

def map_none(&block)
  block.call
end

#map_some(&_block) ⇒ Option::None[InnerType]

Parameters:

Returns:



151
152
153
# File 'lib/mangrove/option.rb', line 151

def map_some(&_block)
  self
end

#none?Boolean

Returns:

  • (Boolean)


148
# File 'lib/mangrove/option.rb', line 148

def none? = true

#some?Boolean

Returns:

  • (Boolean)


145
# File 'lib/mangrove/option.rb', line 145

def some? = false

#transpose(err) ⇒ Mangrove::Result[InnerType, T.type_parameter(:ErrType)]

Parameters:

  • err (T.type_parameter(:ErrType))

Returns:



161
162
163
# File 'lib/mangrove/option.rb', line 161

def transpose(err)
  Result::Err.new(err)
end

#unwrap!InnerType

Returns:

Raises:



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

Parameters:

Returns:



125
126
127
# File 'lib/mangrove/option.rb', line 125

def unwrap_or(default)
  default
end