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?, #deconstruct, #each, #flat_map, #get_or_else, #include?, #initialize, #inspect, #map, #match, matcher, #or_else, #to_option
Instance Method Details
#===(other) ⇒ Boolean
77
78
79
80
81
82
83
|
# File 'lib/fear/left.rb', line 77
def ===(other)
if other.is_a?(Left)
value === other.value
else
super
end
end
|
#join_left ⇒ Either
68
69
70
71
72
|
# File 'lib/fear/left.rb', line 68
def join_left
value.tap do |v|
Utils.assert_type!(v, Either)
end
end
|
#join_right ⇒ self
62
63
64
|
# File 'lib/fear/left.rb', line 62
def join_right
self
end
|
#left? ⇒ true
Also known as:
failure?
30
31
32
|
# File 'lib/fear/left.rb', line 30
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.
19
20
21
|
# File 'lib/fear/left.rb', line 19
def left_value
value
end
|
#reduce(reduce_left, _reduce_right) ⇒ any
57
58
59
|
# File 'lib/fear/left.rb', line 57
def reduce(reduce_left, _reduce_right)
reduce_left.(value)
end
|
#reject ⇒ Left
46
47
48
|
# File 'lib/fear/left.rb', line 46
def reject
self
end
|
#right? ⇒ false
Also known as:
success?
24
25
26
|
# File 'lib/fear/left.rb', line 24
def right?
false
end
|
#select ⇒ Left
41
42
43
|
# File 'lib/fear/left.rb', line 41
def select
self
end
|
#select_or_else ⇒ Either
36
37
38
|
# File 'lib/fear/left.rb', line 36
def select_or_else(*)
self
end
|
Returns value in ‘Right`.
51
52
53
|
# File 'lib/fear/left.rb', line 51
def swap
Right.new(value)
end
|