Module: Fear::RightBiased::Right

Included in:
Fear::Right, Some, Success
Defined in:
lib/fear/right_biased.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


41
42
43
# File 'lib/fear/right_biased.rb', line 41

def included(base)
  base.prepend Interface
end

Instance Method Details

#===(other) ⇒ Boolean

Used in case statement


103
104
105
106
107
108
109
# File 'lib/fear/right_biased.rb', line 103

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

#any? {|value| ... } ⇒ Boolean

Returns true if value satisfies predicate.

Yields:

  • (value)

96
97
98
# File 'lib/fear/right_biased.rb', line 96

def any?
  yield(value)
end

#each {|value| ... } ⇒ self

Yields:

  • (value)

69
70
71
72
# File 'lib/fear/right_biased.rb', line 69

def each
  yield(value)
  self
end

#flat_map {|value| ... } ⇒ RightBiased::Left, RightBiased::Right

Binds the given function across `RightBiased::Right`.

Yields:

  • (value)

86
87
88
# File 'lib/fear/right_biased.rb', line 86

def flat_map
  yield(value)
end

#get_or_else(default) ⇒ any #get_or_else(&default) ⇒ any


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

def get_or_else(*_args)
  value
end

#include?(other_value) ⇒ Boolean


64
65
66
# File 'lib/fear/right_biased.rb', line 64

def include?(other_value)
  value == other_value
end

#mapRightBiased::Right

Maps the value using given block.


78
79
80
# File 'lib/fear/right_biased.rb', line 78

def map
  self.class.new(yield(value))
end

#or_elseself


58
59
60
# File 'lib/fear/right_biased.rb', line 58

def or_else
  self
end

#to_optionOption


91
92
93
# File 'lib/fear/right_biased.rb', line 91

def to_option
  Some.new(value)
end