Class: Option::Some
Instance Method Summary collapse
- #extract_or(default) ⇒ Object
-
#initialize(value) ⇒ Some
constructor
A new instance of Some.
- #with_value ⇒ Object
Methods inherited from Option
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
16 17 18 |
# File 'lib/freshlib/option.rb', line 16 def initialize(value) @value = value end |
Instance Method Details
#extract_or(default) ⇒ Object
29 30 31 |
# File 'lib/freshlib/option.rb', line 29 def extract_or default @value end |
#with_value ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/freshlib/option.rb', line 20 def with_value result = yield @value if result.is_a? Option result else Some.new result end end |