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)


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

Parameters:

  • message (String)

Returns:

Raises:



130
131
132
# File 'lib/mangrove/option.rb', line 130

def expect!(message)
  raise Option::ControlSignal, Result::Err.new(message)
end

#map_none(&block) ⇒ Option[InnerType]

Parameters:

Returns:



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

def map_none(&block)
  block.call
end

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

Parameters:

Returns:



141
142
143
# File 'lib/mangrove/option.rb', line 141

def map_some(&_block)
  self
end

#none?Boolean

Returns:

  • (Boolean)


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

def none? = true

#some?Boolean

Returns:

  • (Boolean)


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

def some? = false

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

Parameters:

  • err (T.type_parameter(:ErrType))

Returns:



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

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

#unwrap!InnerType

Returns:

Raises:



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

Parameters:

Returns:



120
121
122
# File 'lib/mangrove/option.rb', line 120

def unwrap_or(default)
  default
end