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



161
162
163
164
165
# File 'lib/decoding/result.rb', line 161

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

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

#and_then ⇒ Object



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

def and_then = yield(value).to_result

#map ⇒ Object



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

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

#ok? ⇒ Boolean

Returns:

  • (Boolean)


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

def ok? = true

#unwrap(_) ⇒ Object



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

def unwrap(_) = value

#unwrap! ⇒ Object



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

def unwrap! = value