Class: Emu::Ok

Inherits:
Object
  • Object
show all
Defined in:
lib/emu/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Ok

Returns a new instance of Ok.



29
30
31
# File 'lib/emu/result.rb', line 29

def initialize(value)
  @value = value
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/emu/result.rb', line 49

def error?
  false
end

#then {|@value| ... } ⇒ Object

Yields:

  • (@value)


37
38
39
# File 'lib/emu/result.rb', line 37

def then
  yield @value
end

#to_sObject



33
34
35
# File 'lib/emu/result.rb', line 33

def to_s
  "Ok(#{@value})"
end

#unwrapObject



41
42
43
# File 'lib/emu/result.rb', line 41

def unwrap
  @value
end

#unwrap_errObject



45
46
47
# File 'lib/emu/result.rb', line 45

def unwrap_err
  raise "can't unwrap_err Ok(#{@value.inspect})"
end