Class: Fear::Left
- Inherits:
-
Object
show all
- Includes:
- Either
- Defined in:
- lib/fear/left.rb
Instance Method Summary
collapse
Methods included from Either
#any?, #each, #flat_map, #get_or_else, #include?, #initialize, #map, #or_else, #to_a, #to_option
Instance Method Details
#===(other) ⇒ Boolean
60
61
62
63
64
65
66
|
# File 'lib/fear/left.rb', line 60
def ===(other)
if other.is_a?(Left)
value === other.value
else
super
end
end
|
#join_left ⇒ Either
51
52
53
54
55
|
# File 'lib/fear/left.rb', line 51
def join_left
value.tap do |v|
Utils.assert_type!(v, Either)
end
end
|
#join_right ⇒ self
45
46
47
|
# File 'lib/fear/left.rb', line 45
def join_right
self
end
|
#left? ⇒ true
Also known as:
failure?
13
14
15
|
# File 'lib/fear/left.rb', line 13
def left?
true
end
|
#reduce(reduce_left, _) ⇒ any
40
41
42
|
# File 'lib/fear/left.rb', line 40
def reduce(reduce_left, _)
reduce_left.call(value)
end
|
#reject ⇒ Left
29
30
31
|
# File 'lib/fear/left.rb', line 29
def reject
self
end
|
#right? ⇒ false
Also known as:
success?
7
8
9
|
# File 'lib/fear/left.rb', line 7
def right?
false
end
|
#select ⇒ Left
24
25
26
|
# File 'lib/fear/left.rb', line 24
def select
self
end
|
#select_or_else ⇒ Either
19
20
21
|
# File 'lib/fear/left.rb', line 19
def select_or_else(*)
self
end
|
34
35
36
|
# File 'lib/fear/left.rb', line 34
def swap
Right.new(value)
end
|