Class: Kleisli::Validation::Success
- Inherits:
-
Kleisli::Validation
- Object
- Either
- Kleisli::Validation
- Kleisli::Validation::Success
- Defined in:
- lib/kleisli/validation.rb
Constant Summary
Constants inherited from Kleisli::Validation
Instance Method Summary collapse
- #*(other) ⇒ Object
- #>(f) ⇒ Object
- #fmap(&f) ⇒ Object
-
#initialize(right) ⇒ Success
constructor
A new instance of Success.
- #or(other = nil, &other_blk) ⇒ Object
- #to_maybe ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(right) ⇒ Success
Returns a new instance of Success.
28 29 30 |
# File 'lib/kleisli/validation.rb', line 28 def initialize(right) @right = right end |
Instance Method Details
#*(other) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/kleisli/validation.rb', line 20 def *(other) if other.class == Success super else other end end |
#>(f) ⇒ Object
32 33 34 |
# File 'lib/kleisli/validation.rb', line 32 def >(f) f.call(@right) end |
#fmap(&f) ⇒ Object
36 37 38 |
# File 'lib/kleisli/validation.rb', line 36 def fmap(&f) Success.new(f.call(@right)) end |
#or(other = nil, &other_blk) ⇒ Object
44 45 46 |
# File 'lib/kleisli/validation.rb', line 44 def or(other=nil, &other_blk) self end |
#to_maybe ⇒ Object
40 41 42 |
# File 'lib/kleisli/validation.rb', line 40 def to_maybe Maybe::Some.new(@right) end |
#to_s ⇒ Object Also known as: inspect
48 49 50 |
# File 'lib/kleisli/validation.rb', line 48 def to_s "Success(#{@right.inspect})" end |