Class: NotMonads::Result::Success
- Inherits:
-
NotMonads::Result
- Object
- NotMonads::Result
- NotMonads::Result::Success
- 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) ⇒ Success
constructor
A new instance of Success.
- #success? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
- #value! ⇒ Object
- #value_or(_val = nil) ⇒ Object
Constructor Details
#initialize(value) ⇒ Success
Returns a new instance of Success.
8 9 10 11 |
# File 'lib/not_monads/result.rb', line 8 def initialize(value) super() @success = value end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 |
# File 'lib/not_monads/result.rb', line 34 def ==(other) other.is_a?(self.class) && value! == other.value! end |
#===(other) ⇒ Object
38 39 40 |
# File 'lib/not_monads/result.rb', line 38 def ===(other) other.instance_of?(self.class) && value! === other.value! end |
#failure? ⇒ Boolean
13 14 15 |
# File 'lib/not_monads/result.rb', line 13 def failure? false end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/not_monads/result.rb', line 17 def success? true end |
#to_s ⇒ Object Also known as: inspect
21 22 23 |
# File 'lib/not_monads/result.rb', line 21 def to_s "Success(#{success.inspect})" end |
#value! ⇒ Object
26 27 28 |
# File 'lib/not_monads/result.rb', line 26 def value! success end |
#value_or(_val = nil) ⇒ Object
30 31 32 |
# File 'lib/not_monads/result.rb', line 30 def value_or(_val = nil) success end |