class Opted::Result::Err

Value object that represents an error result

Public Class Methods

new(error) click to toggle source

@param error [Object] a non-nil error to wrap @raise [ArgumentError] if provided error is nil

# File lib/opted/result/err.rb, line 7
def initialize(error)
  if error.nil?
    fail ArgumentError.new("can't wrap nil")
  else
    @error = error
  end
end

Public Instance Methods

==(other) click to toggle source

If other object is also {Err} and wraps equivalent error @param other [Object] any object @return [Boolean]

# File lib/opted/result/err.rb, line 18
def ==(other)
  other.is_a?(Err) && unwrap_err! == other.unwrap_err!
end
Also aliased as: eql?
and(_other) click to toggle source

(see AbstractResult#and) @see Ok#and

# File lib/opted/result/err.rb, line 67
def and(_other)
  self
end
and_then() click to toggle source

(see AbstractResult#and_then) @see Ok#and_then

# File lib/opted/result/err.rb, line 73
def and_then
  self
end
eql?(other)
Alias for: ==
err?() click to toggle source

(see AbstractResult#err?) @see Ok#err?

# File lib/opted/result/err.rb, line 31
def err?
  true
end
map() click to toggle source

(see AbstractResult#map) @see Ok#map

# File lib/opted/result/err.rb, line 49
def map
  self
end
map_err() { |unwrap_err!)| ... } click to toggle source

(see AbstractResult#map_err) @see Ok#map_err

# File lib/opted/result/err.rb, line 55
def map_err
  Err.new(yield unwrap_err!)
end
match(&block) click to toggle source

(see AbstractResult#match) @see Ok#match

# File lib/opted/result/err.rb, line 91
def match(&block)
  Match.match_error(unwrap_err!, &block)
end
ok?() click to toggle source

(see AbstractResult#ok?) @see Ok#ok?

# File lib/opted/result/err.rb, line 25
def ok?
  false
end
or(other) click to toggle source

(see AbstractResult#or) @see Ok#or

# File lib/opted/result/err.rb, line 79
def or(other)
  other
end
or_else() { |unwrap_err!| ... } click to toggle source

(see AbstractResult#or_else) @see Ok#or_else

# File lib/opted/result/err.rb, line 85
def or_else
  yield unwrap_err!
end
unwrap!() click to toggle source

(see AbstractResult#unwrap!) @see Ok#unwrap!

# File lib/opted/result/err.rb, line 37
def unwrap!
  fail UnwrapError.new(__method__, inspect)
end
unwrap_err!() click to toggle source

(see AbstractResult#unwrap_err!) @see Ok#unwrap_err!

# File lib/opted/result/err.rb, line 43
def unwrap_err!
  @error
end
unwrap_or(other_value) click to toggle source

(see AbstractResult#unwrap_or) @see Ok#unwrap_or

# File lib/opted/result/err.rb, line 61
def unwrap_or(other_value)
  other_value
end