Class: Errgonomic::Result::Ok

Inherits:
Any show all
Defined in:
lib/errgonomic/result.rb

Overview

The Ok variant.

Constant Summary

Constants inherited from Any

Any::RUST_SPELLINGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Any

#<=>, #==, #and, #and_then, #deconstruct, #eql?, #err_and?, #expect!, #hash, #initialize, #map, #map_err, #method_missing, #ok_and?, #or, #or_else, #pretty_print, #respond_to_missing?, #result?, #tap_err, #tap_ok, #to_json, #to_s, #unwrap!, #unwrap_err!, #unwrap_or, #unwrap_or_else

Constructor Details

This class inherits a constructor from Errgonomic::Result::Any

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Errgonomic::Result::Any

Instance Attribute Details

#valueObject

Returns the value of attribute value.



404
405
406
# File 'lib/errgonomic/result.rb', line 404

def value
  @value
end

Instance Method Details

#err?Boolean

Ok is never err

Examples:

Ok(1).err? # => false

Returns:

  • (Boolean)


418
419
420
# File 'lib/errgonomic/result.rb', line 418

def err?
  false
end

#inspectObject

Render like Rust's Debug, delegating to the inner value's inspect.

Examples:

Ok(1).inspect # => "Ok(1)"
Ok("x").inspect # => "Ok(\"x\")"


427
428
429
# File 'lib/errgonomic/result.rb', line 427

def inspect
  "Ok(#{value.inspect})"
end

#ok?Boolean

Ok is always ok

Examples:

Ok(1).ok? # => true

Returns:

  • (Boolean)


410
411
412
# File 'lib/errgonomic/result.rb', line 410

def ok?
  true
end