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, #eql?, err, #err?, #initialize, #inspect, #map_err, ok, #to_result

Constructor Details

This class inherits a constructor from Decoding::Result

Instance Method Details

#and(other) ⇒ Object



135
136
137
138
139
# File 'lib/decoding/result.rb', line 135

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

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

#and_thenObject



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

def and_then = yield(value).to_result

#mapObject



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

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

#ok?Boolean

Returns:

  • (Boolean)


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

def ok? = true

#unwrap(_) ⇒ Object



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

def unwrap(_) = value