Top Level Namespace

Defined Under Namespace

Classes: Maybe, None, Some

Instance Method Summary collapse

Instance Method Details

#Maybe(value, parent_stack = [], inst_method = nil) ⇒ Object

rubocop:disable MethodName



226
227
228
229
230
231
232
233
# File 'lib/possibly.rb', line 226

def Maybe(value, parent_stack = [], inst_method = nil)
  inst_method ||= ["Maybe", []]
  if value.nil? || (value.respond_to?(:length) && value.length == 0)
    None(inst_method, parent_stack)
  else
    Some(value, inst_method, parent_stack)
  end
end

#None(inst_method = nil, parent_stack = []) ⇒ Object



240
241
242
243
# File 'lib/possibly.rb', line 240

def None(inst_method = nil, parent_stack = [])
  inst_method ||= ["None", []]
  None.new(inst_method, parent_stack)
end

#Some(value, inst_method = nil, parent_stack = []) ⇒ Object



235
236
237
238
# File 'lib/possibly.rb', line 235

def Some(value, inst_method = nil, parent_stack = [])
  inst_method ||= ["Some", []]
  Some.new(value, inst_method, parent_stack)
end