Class: Option::Some
Constant Summary
Trither::BasicTypes::C, Trither::BasicTypes::Func0, Trither::BasicTypes::Func1, Trither::BasicTypes::Predicate
Constants inherited
from Trither::Box
Trither::Box::C
Instance Method Summary
collapse
#==, #initialize
Constructor Details
This class inherits a constructor from Trither::Box
Instance Method Details
#empty? ⇒ Boolean
90
91
92
|
# File 'lib/trither/option.rb', line 90
def empty?
false
end
|
#fetch(_default) ⇒ Object
100
101
102
|
# File 'lib/trither/option.rb', line 100
def fetch(_default)
@value
end
|
#filter ⇒ Object
95
96
97
|
# File 'lib/trither/option.rb', line 95
def filter
yield(@value) ? self : None
end
|
#flat_map ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/trither/option.rb', line 110
def flat_map
result = yield @value
if result.nil?
None
else
result
end
end
|
#get_or_else ⇒ Object
125
126
127
|
# File 'lib/trither/option.rb', line 125
def get_or_else
@value
end
|
#map ⇒ Object
105
106
107
|
# File 'lib/trither/option.rb', line 105
def map
Option.make(yield @value)
end
|
#or_else ⇒ Object
120
121
122
|
# File 'lib/trither/option.rb', line 120
def or_else
self
end
|