Class: NotMonads::Result::Failure
- Inherits:
-
NotMonads::Result
- Object
- NotMonads::Result
- NotMonads::Result::Failure
- Defined in:
- lib/not_monads/result.rb
Instance Attribute Summary
Attributes inherited from NotMonads::Result
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(value) ⇒ Failure
constructor
A new instance of Failure.
- #success? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
- #value! ⇒ Object
- #value_or(val = nil) ⇒ Object
Constructor Details
#initialize(value) ⇒ Failure
Returns a new instance of Failure.
44 45 46 47 |
# File 'lib/not_monads/result.rb', line 44 def initialize(value) super() @failure = value end |
Instance Method Details
#==(other) ⇒ Object
74 75 76 |
# File 'lib/not_monads/result.rb', line 74 def ==(other) other.is_a?(self.class) && failure == other.failure end |
#===(other) ⇒ Object
78 79 80 |
# File 'lib/not_monads/result.rb', line 78 def ===(other) other.instance_of?(self.class) && failure === other.failure end |
#failure? ⇒ Boolean
49 50 51 |
# File 'lib/not_monads/result.rb', line 49 def failure? true end |
#success? ⇒ Boolean
53 54 55 |
# File 'lib/not_monads/result.rb', line 53 def success? false end |
#to_s ⇒ Object Also known as: inspect
57 58 59 |
# File 'lib/not_monads/result.rb', line 57 def to_s "Failure(#{failure.inspect})" end |
#value! ⇒ Object
62 63 64 |
# File 'lib/not_monads/result.rb', line 62 def value! raise Error, "value! was called on #{self}" end |
#value_or(val = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/not_monads/result.rb', line 66 def value_or(val = nil) if block_given? yield else val end end |