Class: Kind::Either::Left

Inherits:
Monad
  • Object
show all
Defined in:
lib/kind/either/left.rb

Instance Attribute Summary

Attributes inherited from Monad

#value

Instance Method Summary collapse

Methods inherited from Monad

#===, #either?, #initialize, #on, #on_left, #on_right, #right?

Constructor Details

This class inherits a constructor from Kind::Either::Monad

Instance Method Details

#inspectObject



25
26
27
# File 'lib/kind/either/left.rb', line 25

def inspect
  '#<%s value=%p>' % ['Kind::Left', value]
end

#left?Boolean

Returns:



5
6
7
# File 'lib/kind/either/left.rb', line 5

def left?
  true
end

#map(&_) ⇒ Object Also known as: map!, then, then!, and_then, and_then!



15
16
17
# File 'lib/kind/either/left.rb', line 15

def map(&_)
  self
end

#value_or(default = UNDEFINED, &block) ⇒ Object



9
10
11
12
13
# File 'lib/kind/either/left.rb', line 9

def value_or(default = UNDEFINED, &block)
  Error.invalid_default_arg! if UNDEFINED == default && !block

  UNDEFINED != default ? default : block.call(value)
end