Class: Fear::Left

Inherits:
Object
  • Object
show all
Includes:
Either
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

Instance Method Summary collapse

Methods included from Either

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

Instance Method Details

#===(other) ⇒ Boolean

Used in case statement

Parameters:

  • other (any)

Returns:

  • (Boolean)


74
75
76
77
78
79
80
# File 'lib/fear/left.rb', line 74

def ===(other)
  if other.is_a?(Left)
    value === other.value
  else
    super
  end
end

#join_leftEither

Returns:

Raises:

  • (TypeError)


65
66
67
68
69
# File 'lib/fear/left.rb', line 65

def join_left
  value.tap do |v|
    Utils.assert_type!(v, Either)
  end
end

#join_rightself

Returns:

  • (self)


59
60
61
# File 'lib/fear/left.rb', line 59

def join_right
  self
end

#left?true Also known as: failure?

Returns:

  • (true)


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

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.



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

def left_value
  value
end

#reduce(reduce_left, _reduce_right) ⇒ any

Parameters:

  • reduce_left (Proc)

Returns:

  • (any)


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

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

#rejectLeft

Returns:



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

def reject
  self
end

#right?false Also known as: success?

Returns:

  • (false)


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

def right?
  false
end

#selectLeft

Returns:



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

def select
  self
end

#select_or_elseEither

Returns:



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

def select_or_else(*)
  self
end

#swapRight

Returns value in ‘Right`.

Returns:

  • (Right)

    value in ‘Right`



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

def swap
  Right.new(value)
end