Class: Mutant::Either::Right Private

Inherits:
Mutant::Either show all
Defined in:
lib/mutant/base.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Left

Instance Method Summary collapse

Methods inherited from Mutant::Either

wrap_error

Instance Method Details

#apply {|value| ... } ⇒ Either<Object>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate applicative block

Yields:

  • (value)

Returns:



151
152
153
# File 'lib/mutant/base.rb', line 151

def apply
  yield(value)
end

#either(_left, right) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate right side of branch

Parameters:

  • _left (#call)
  • right (#call)


187
188
189
# File 'lib/mutant/base.rb', line 187

def either(_left, right)
  right.call(value)
end

#fmapEither::Right<Object>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate functor block

Returns:



144
145
146
# File 'lib/mutant/base.rb', line 144

def fmap
  Right.new(yield(value))
end

#from_leftObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Unwrap value from left

rubocop:disable Style/GuardClause

Returns:

  • (Object)


160
161
162
163
164
165
166
# File 'lib/mutant/base.rb', line 160

def from_left
  if block_given?
    yield(value)
  else
    fail "Expected left value, got #{inspect}"
  end
end

#from_rightObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Unwrap value from right

Returns:

  • (Object)


172
173
174
# File 'lib/mutant/base.rb', line 172

def from_right
  value
end

#lmap(&block) ⇒ Either::Right<Object>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Map over left value

Returns:



179
180
181
# File 'lib/mutant/base.rb', line 179

def lmap(&block)
  require_block(&block)
end