Class: Fear::Left

Inherits:
Object
  • Object
show all
Includes:
Either, RightBiased::Left
Defined in:
lib/fear/left.rb

Constant Summary collapse

EXTRACTOR =
proc do |either|
  if Fear::Left === either
    Fear.some([either.left_value])
  else
    Fear.none
  end
end

Constants included from Utils

Utils::UNDEFINED

Instance Method Summary collapse

Methods included from RightBiased::Left

#any?, #each, #flat_map, #get_or_else, #include?, #map, #or_else, #to_option

Methods included from Utils

assert_arg_or_block!, assert_type!, return_or_call_proc, with_block_or_argument

Methods included from Either

#==, #any?, #each, #flat_map, #get_or_else, #include?, #initialize, #inspect, #left_class, #map, #match, matcher, #or_else, #right_class, #to_option

Instance Method Details

#===(other) ⇒ Boolean

Used in case statement


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_leftEither

Raises:

  • (TypeError)

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_rightself


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_valueObject

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

#rejectLeft


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

#selectLeft


40
41
42
# File 'lib/fear/left.rb', line 40

def select
  self
end

#select_or_elseEither


35
36
37
# File 'lib/fear/left.rb', line 35

def select_or_else(*)
  self
end

#swapRight


50
51
52
# File 'lib/fear/left.rb', line 50

def swap
  Right.new(value)
end