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
74
75
76
77
78
79
80
|
# File 'lib/fear/left.rb', line 74
def ===(other)
if other.is_a?(Left)
value === other.value
else
super
end
end
|
#join_left ⇒ Either
65
66
67
68
69
|
# File 'lib/fear/left.rb', line 65
def join_left
value.tap do |v|
Utils.assert_type!(v, Either)
end
end
|
#join_right ⇒ self
59
60
61
|
# File 'lib/fear/left.rb', line 59
def join_right
self
end
|
#left? ⇒ true
Also known as:
failure?
27
28
29
|
# File 'lib/fear/left.rb', line 27
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.
16
17
18
|
# File 'lib/fear/left.rb', line 16
def left_value
value
end
|
#reduce(reduce_left, _reduce_right) ⇒ any
54
55
56
|
# File 'lib/fear/left.rb', line 54
def reduce(reduce_left, _reduce_right)
reduce_left.call(value)
end
|
#reject ⇒ Left
43
44
45
|
# File 'lib/fear/left.rb', line 43
def reject
self
end
|
#right? ⇒ false
Also known as:
success?
21
22
23
|
# File 'lib/fear/left.rb', line 21
def right?
false
end
|
#select ⇒ Left
38
39
40
|
# File 'lib/fear/left.rb', line 38
def select
self
end
|
#select_or_else ⇒ Either
33
34
35
|
# File 'lib/fear/left.rb', line 33
def select_or_else(*)
self
end
|
Returns value in ‘Right`.
48
49
50
|
# File 'lib/fear/left.rb', line 48
def swap
Right.new(value)
end
|