Module: Fear::Option::Mixin

Included in:
Mixin
Defined in:
lib/fear/option.rb

Overview

Include this mixin to access convenient factory methods.

Examples:

include Fear::Option::Mixin

Option(17) #=> #<Fear::Some get=17>
Option(nil) #=> #<Fear::None>
Some(17) #=> #<Fear::Some get=17>
None() #=> #<Fear::None>

Instance Method Summary collapse

Instance Method Details

#NoneNone

Examples:

None() #=> #<Fear::None>

Returns:



245
246
247
# File 'lib/fear/option.rb', line 245

def None
  Fear.none
end

#Option(value) ⇒ Fear::Some, Fear::None

An Option factory which creates Some if the argument is not nil, and None if it is nil.

Examples:

Option(17) #=> #<Fear::Some get=17>
Option(nil) #=> #<Fear::None>

Parameters:

  • value (any)

Returns:



237
238
239
# File 'lib/fear/option.rb', line 237

def Option(value)
  Fear.option(value)
end

#Some(value) ⇒ Fear::Some

Examples:

Some(17) #=> #<Fear::Some get=17>
Some(nil) #=> #<Fear::Some get=nil>

Parameters:

  • value (any)

    except nil

Returns:



255
256
257
# File 'lib/fear/option.rb', line 255

def Some(value)
  Fear.some(value)
end