class RFunc::AbstractOption
Public Class Methods
new(value)
click to toggle source
Initializes the class
@param value [Any] the initial value of the Option
@return [AbstractOption] and instance of the class
# File lib/rfunc/option.rb, line 11 def initialize(value) @value = value end
Public Instance Methods
==(object)
click to toggle source
filter() { |el| ... }
click to toggle source
Filters the Some
by a given function
@param block [Function] the function which will operate on the
option's value if present (should return Bool) and be used to determine if a Some of None will be returned
@return [RFunc::Option] the Option
result of the filter
# File lib/rfunc/option.rb, line 38 def filter(&block) map {|el| yield(el)}.get_or_else { false } ? self : None.new end
Also aliased as: find
filter_not() { |el| ... }
click to toggle source
Filters the Some
by the inverse of a given function
@param block [Function] the function which will operate on the
option's value if present (should return Bool) and be used to determine if a Some of None will be returned
@return [RFunc::Option] the Option
result of the filter
# File lib/rfunc/option.rb, line 50 def filter_not(&block) map {|el| !yield(el) }.get_or_else { false } ? self : None.new end
get()
click to toggle source
Extracts the value of the option
@return [Any] the value of the option
# File lib/rfunc/option.rb, line 28 def get; @value end
Private Instance Methods
validated_option_type(r)
click to toggle source
# File lib/rfunc/option.rb, line 68 def validated_option_type(r) raise RFunc::Errors::InvalidReturnType.new(r, AbstractOption) if !is_option?(r) r end