class Kind::Either::Monad
Attributes
value[R]
Public Class Methods
new(value)
click to toggle source
# File lib/kind/either/monad.rb, line 11 def initialize(value) @value = value end
Public Instance Methods
===(monad)
click to toggle source
# File lib/kind/either/monad.rb, line 61 def ===(monad) self.class === monad && self.value === monad.value end
either?(matcher)
click to toggle source
# File lib/kind/either/monad.rb, line 57 def either?(matcher) UNDEFINED == matcher || matcher === value end
left?()
click to toggle source
# File lib/kind/either/monad.rb, line 15 def left? false end
map(&_)
click to toggle source
# File lib/kind/either/monad.rb, line 27 def map(&_) raise NotImplementedError end
on() { |monad| ... }
click to toggle source
# File lib/kind/either/monad.rb, line 37 def on monad = Wrapper.new(self) yield(monad) monad.output end
on_left(matcher = UNDEFINED) { |value| ... }
click to toggle source
# File lib/kind/either/monad.rb, line 51 def on_left(matcher = UNDEFINED) yield(value) if left? && either?(matcher) self end
on_right(matcher = UNDEFINED) { |value| ... }
click to toggle source
# File lib/kind/either/monad.rb, line 45 def on_right(matcher = UNDEFINED) yield(value) if right? && either?(matcher) self end
right?()
click to toggle source
# File lib/kind/either/monad.rb, line 19 def right? false end
value_or(_method_name = UNDEFINED, &block)
click to toggle source
# File lib/kind/either/monad.rb, line 23 def value_or(_method_name = UNDEFINED, &block) raise NotImplementedError end