Class: Fear::Left
- Inherits:
-
Object
show all
- Includes:
- Either
- Defined in:
- lib/fear/left.rb,
lib/fear/left/pattern_match.rb
Instance Method Summary
collapse
Methods included from Either
#==, #any?, #deconstruct, #each, #flat_map, #get_or_else, #include?, #initialize, #inspect, #left, #map, #match, matcher, #or_else, #to_option
Instance Method Details
#===(other) ⇒ Boolean
68
69
70
71
72
73
74
|
# File 'lib/fear/left.rb', line 68
def ===(other)
if other.is_a?(Left)
value === other.value
else
super
end
end
|
#join_left ⇒ Either
59
60
61
62
63
|
# File 'lib/fear/left.rb', line 59
def join_left
value.tap do |v|
Utils.assert_type!(v, Either)
end
end
|
#join_right ⇒ self
53
54
55
|
# File 'lib/fear/left.rb', line 53
def join_right
self
end
|
#left? ⇒ true
Also known as:
failure?
21
22
23
|
# File 'lib/fear/left.rb', line 21
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.
10
11
12
|
# File 'lib/fear/left.rb', line 10
def left_value
value
end
|
#reduce(reduce_left, _reduce_right) ⇒ any
48
49
50
|
# File 'lib/fear/left.rb', line 48
def reduce(reduce_left, _reduce_right)
reduce_left.(value)
end
|
#reject ⇒ Left
37
38
39
|
# File 'lib/fear/left.rb', line 37
def reject
self
end
|
#right? ⇒ false
Also known as:
success?
15
16
17
|
# File 'lib/fear/left.rb', line 15
def right?
false
end
|
#select ⇒ Left
32
33
34
|
# File 'lib/fear/left.rb', line 32
def select
self
end
|
#select_or_else ⇒ Either
27
28
29
|
# File 'lib/fear/left.rb', line 27
def select_or_else(*)
self
end
|
Returns value in ‘Right`.
42
43
44
|
# File 'lib/fear/left.rb', line 42
def swap
Right.new(value)
end
|