Class: Option::Some

Inherits:
Option show all
Defined in:
lib/freshlib/option.rb

Instance Method Summary collapse

Methods inherited from Option

None, Some

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_valueObject



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