Class: Fear::Left

Inherits:
Object
  • 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

Used in case statement

Parameters:

  • other (any)

Returns:

  • (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_leftEither

Returns:

Raises:

  • (TypeError)


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_rightself

Returns:

  • (self)


53
54
55
# File 'lib/fear/left.rb', line 53

def join_right
  self
end

#left?true Also known as: failure?

Returns:

  • (true)


21
22
23
# File 'lib/fear/left.rb', line 21

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.



10
11
12
# File 'lib/fear/left.rb', line 10

def left_value
  value
end

#reduce(reduce_left, _reduce_right) ⇒ any

Parameters:

  • reduce_left (Proc)

Returns:

  • (any)


48
49
50
# File 'lib/fear/left.rb', line 48

def reduce(reduce_left, _reduce_right)
  reduce_left.(value)
end

#rejectLeft

Returns:



37
38
39
# File 'lib/fear/left.rb', line 37

def reject
  self
end

#right?false Also known as: success?

Returns:

  • (false)


15
16
17
# File 'lib/fear/left.rb', line 15

def right?
  false
end

#selectLeft

Returns:



32
33
34
# File 'lib/fear/left.rb', line 32

def select
  self
end

#select_or_elseEither

Returns:



27
28
29
# File 'lib/fear/left.rb', line 27

def select_or_else(*)
  self
end

#swapRight

Returns value in ‘Right`.

Returns:

  • (Right)

    value in ‘Right`



42
43
44
# File 'lib/fear/left.rb', line 42

def swap
  Right.new(value)
end