Class: Fear::Left
- Inherits:
-
Object
show all
- Includes:
- Either
- Defined in:
- lib/fear/left.rb
Constant Summary
collapse
proc do |either|
if Fear::Left === either
Fear.some([either.left_value])
else
Fear.none
end
end
Instance Method Summary
collapse
Methods included from Either
#==, #any?, #each, #flat_map, #get_or_else, #include?, #initialize, #inspect, #map, #match, matcher, #or_else, #to_option
Instance Method Details
#===(other) ⇒ Boolean
76
77
78
79
80
81
82
|
# File 'lib/fear/left.rb', line 76
def ===(other)
if other.is_a?(Left)
value === other.value
else
super
end
end
|
#join_left ⇒ Either
67
68
69
70
71
|
# File 'lib/fear/left.rb', line 67
def join_left
value.tap do |v|
Utils.assert_type!(v, Either)
end
end
|
#join_right ⇒ self
61
62
63
|
# File 'lib/fear/left.rb', line 61
def join_right
self
end
|
#left? ⇒ true
Also known as:
failure?
29
30
31
|
# File 'lib/fear/left.rb', line 29
def left?
true
end
|
#left_value ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
18
19
20
|
# File 'lib/fear/left.rb', line 18
def left_value
value
end
|
#reduce(reduce_left, _reduce_right) ⇒ any
56
57
58
|
# File 'lib/fear/left.rb', line 56
def reduce(reduce_left, _reduce_right)
reduce_left.(value)
end
|
#reject ⇒ Left
45
46
47
|
# File 'lib/fear/left.rb', line 45
def reject
self
end
|
#right? ⇒ false
Also known as:
success?
23
24
25
|
# File 'lib/fear/left.rb', line 23
def right?
false
end
|
#select ⇒ Left
40
41
42
|
# File 'lib/fear/left.rb', line 40
def select
self
end
|
#select_or_else ⇒ Either
35
36
37
|
# File 'lib/fear/left.rb', line 35
def select_or_else(*)
self
end
|
Returns value in ‘Right`.
50
51
52
|
# File 'lib/fear/left.rb', line 50
def swap
Right.new(value)
end
|