Module: Functional

Extended by:
Functional
Included in:
Functional
Defined in:
lib/maybe.rb

Defined Under Namespace

Classes: None, Option, Some

Instance Method Summary collapse

Instance Method Details

#NoneObject



115
116
117
# File 'lib/maybe.rb', line 115

def None
  None.new
end

#Option(value) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/maybe.rb', line 88

def Option(value)
  if value.nil? || (value.respond_to?(:length) && value.length == 0)
    None()
  else
    Some(value)
  end
end

#Some(value) ⇒ Object



144
145
146
# File 'lib/maybe.rb', line 144

def Some(value)
  Some.new(value)
end