class Mon::Monad::Failure

Public Class Methods

[](err) click to toggle source
# File lib/monads/try.rb, line 127
def self.[](err)
  self.new(err)
end
valid?(o) click to toggle source
# File lib/monads/try.rb, line 179
def self::valid?(o)
  o.is_a? self.class
end

Protected Class Methods

new(err) click to toggle source
# File lib/monads/try.rb, line 123
def initialize(err)
  @err = err
end

Public Instance Methods

==(o) click to toggle source
# File lib/monads/try.rb, line 171
def ==(o)
  eql?(o)
end
bind(&fun) click to toggle source
# File lib/monads/try.rb, line 131
def bind &fun
  self
end
eql?(other) click to toggle source
# File lib/monads/try.rb, line 167
def eql?(other)
  (other.is_a? Failure) ? (@err == other.unwrap) : false
end
equal?(o) click to toggle source
# File lib/monads/try.rb, line 175
def equal?(o)
  eql?(o)
end
or(obj, &f) click to toggle source
# File lib/monads/try.rb, line 135
def or obj, &f
  if f and obj
    f.call(obj)
  elsif f
    f.call
  else
    obj
  end
end
orFail(&f) click to toggle source
# File lib/monads/try.rb, line 145
def orFail &f
  if f
    f.call(@err)
  elsif @err.is_a? Exception
    raise @err
  else
    @err
  end
end
to_s() click to toggle source
# File lib/monads/try.rb, line 163
def to_s
  "Failure[#{@err}]"
end

Protected Instance Methods

_canBind?(name) click to toggle source
# File lib/monads/try.rb, line 159
def _canBind? name
  true
end
unwrap() click to toggle source
# File lib/monads/try.rb, line 155
def unwrap
  @err
end