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)


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

Returns:

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

Returns:

  • (self)


61
62
63
# File 'lib/fear/left.rb', line 61

def join_right
  self
end

#left?true Also known as: failure?

Returns:

  • (true)


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

Parameters:

  • reduce_left (Proc)

Returns:

  • (any)


56
57
58
# File 'lib/fear/left.rb', line 56

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

#rejectLeft

Returns:



45
46
47
# File 'lib/fear/left.rb', line 45

def reject
  self
end

#right?false Also known as: success?

Returns:

  • (false)


23
24
25
# File 'lib/fear/left.rb', line 23

def right?
  false
end

#selectLeft

Returns:



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

def select
  self
end

#select_or_elseEither

Returns:



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

def select_or_else(*)
  self
end

#swapRight

Returns value in ‘Right`.

Returns:

  • (Right)

    value in ‘Right`



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

def swap
  Right.new(value)
end