class Kind::Maybe::Monad
Attributes
value[R]
Public Class Methods
new(value)
click to toggle source
# File lib/kind/maybe/monad.rb, line 12 def initialize(value) @value = Value[value] end
Public Instance Methods
check(&fn)
click to toggle source
# File lib/kind/maybe/monad.rb, line 36 def check(&fn) raise NotImplementedError end
dig(*keys)
click to toggle source
# File lib/kind/maybe/monad.rb, line 49 def dig(*keys) raise NotImplementedError end
map(&fn)
click to toggle source
# File lib/kind/maybe/monad.rb, line 26 def map(&fn) raise NotImplementedError end
maybe?(matcher)
click to toggle source
# File lib/kind/maybe/monad.rb, line 77 def maybe?(matcher) UNDEFINED == matcher || matcher === value end
none?()
click to toggle source
# File lib/kind/maybe/monad.rb, line 20 def none? raise NotImplementedError end
on() { |monad| ... }
click to toggle source
# File lib/kind/maybe/monad.rb, line 57 def on monad = Wrapper.new(self) yield(monad) monad.output end
on_none(matcher = UNDEFINED) { |value| ... }
click to toggle source
# File lib/kind/maybe/monad.rb, line 71 def on_none(matcher = UNDEFINED) yield(value) if none? && maybe?(matcher) self end
on_some(matcher = UNDEFINED) { |value| ... }
click to toggle source
# File lib/kind/maybe/monad.rb, line 65 def on_some(matcher = UNDEFINED) yield(value) if some? && maybe?(matcher) self end
presence()
click to toggle source
# File lib/kind/maybe/monad.rb, line 53 def presence raise NotImplementedError end
some?()
click to toggle source
# File lib/kind/maybe/monad.rb, line 24 def some?; !none?; end
try(_method_name = UNDEFINED, &block)
click to toggle source
# File lib/kind/maybe/monad.rb, line 43 def try(_method_name = UNDEFINED, &block) raise NotImplementedError end
Also aliased as: try!
value_or(_method_name = UNDEFINED, &block)
click to toggle source
# File lib/kind/maybe/monad.rb, line 16 def value_or(_method_name = UNDEFINED, &block) raise NotImplementedError end