Class: Decoding::Ok

Inherits:
Result show all
Defined in:
lib/decoding/result.rb

Overview

The Ok value represents the result of a successful computation.

See Also:

Instance Attribute Summary

Attributes inherited from Result

#hash

Instance Method Summary collapse

Methods inherited from Result

all, #deconstruct, #eql?, err, #err?, #initialize, #inspect, #map_err, ok, #to_result, #unwrap_err

Constructor Details

This class inherits a constructor from Decoding::Result

Instance Method Details

#and(other) ⇒ Object



147
148
149
150
151
# File 'lib/decoding/result.rb', line 147

def and(other)
  return other unless other.is_a?(self.class)

  self.class.new(yield value, other.value)
end

#and_thenObject



153
# File 'lib/decoding/result.rb', line 153

def and_then = yield(value).to_result

#mapObject



145
# File 'lib/decoding/result.rb', line 145

def map = self.class.new(yield value)

#ok?Boolean

Returns:

  • (Boolean)


143
# File 'lib/decoding/result.rb', line 143

def ok? = true

#unwrap(_) ⇒ Object



144
# File 'lib/decoding/result.rb', line 144

def unwrap(_) = value