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

accept(&fn)
Alias for: check
and_then(&fn)
Alias for: map
and_then!(&fn)
Alias for: map!
check(&fn) click to toggle source
# File lib/kind/maybe/monad.rb, line 36
def check(&fn)
  raise NotImplementedError
end
Also aliased as: accept, reject
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
Also aliased as: map!, then, then!, and_then
map!(&fn)
Also aliased as: and_then!
Alias for: map
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
reject(&fn)
Alias for: check
some?() click to toggle source
# File lib/kind/maybe/monad.rb, line 24
def some?; !none?; end
then(&fn)
Alias for: map
then!(&fn)
Alias for: map
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!
try!(_method_name = UNDEFINED, &block)
Alias for: 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