Class: Option::Some
- Inherits:
-
Object
- Object
- Option::Some
- Defined in:
- lib/trither/option.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #fetch(_default) ⇒ Object
- #flat_map ⇒ Object
- #get_or_else ⇒ Object
-
#initialize(value) ⇒ Some
constructor
A new instance of Some.
- #map ⇒ Object
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
33 34 35 |
# File 'lib/trither/option.rb', line 33 def initialize(value) @value = value end |
Instance Method Details
#empty? ⇒ Boolean
37 38 39 |
# File 'lib/trither/option.rb', line 37 def empty? false end |
#fetch(_default) ⇒ Object
41 42 43 |
# File 'lib/trither/option.rb', line 41 def fetch(_default) @value end |
#flat_map ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/trither/option.rb', line 49 def flat_map result = yield @value if result.nil? None else result end end |
#get_or_else ⇒ Object
58 59 60 |
# File 'lib/trither/option.rb', line 58 def get_or_else @value end |
#map ⇒ Object
45 46 47 |
# File 'lib/trither/option.rb', line 45 def map Option.make(yield @value) end |