Module: Sheetah::Utils::MonadicResult::Result
Constant Summary collapse
- UnwrapError =
Class.new(StandardError)
- VariantError =
Class.new(UnwrapError)
- ValueError =
Class.new(UnwrapError)
Instance Method Summary collapse
- #==(other) ⇒ Object
- #discard ⇒ Object
- #empty? ⇒ Boolean
- #initialize(value = Unit) ⇒ Object
- #inspect ⇒ Object (also: #to_s)
Instance Method Details
#==(other) ⇒ Object
44 45 46 |
# File 'lib/sheetah/utils/monadic_result.rb', line 44 def ==(other) other.is_a?(self.class) && other.wrapped == wrapped end |
#discard ⇒ Object
58 59 60 |
# File 'lib/sheetah/utils/monadic_result.rb', line 58 def discard empty? ? self : self.class.new end |
#empty? ⇒ Boolean
40 41 42 |
# File 'lib/sheetah/utils/monadic_result.rb', line 40 def empty? wrapped == Unit end |
#initialize(value = Unit) ⇒ Object
36 37 38 |
# File 'lib/sheetah/utils/monadic_result.rb', line 36 def initialize(value = Unit) @wrapped = value end |
#inspect ⇒ Object Also known as: to_s
48 49 50 51 52 53 54 |
# File 'lib/sheetah/utils/monadic_result.rb', line 48 def inspect if empty? "#{variant}()" else "#{variant}(#{wrapped.inspect})" end end |