Class: Monadic::Nothing

Inherits:
Maybe show all
Defined in:
lib/monadic/maybe.rb

Class Method Summary collapse

Methods inherited from Maybe

#empty?, #select, #to_ary, #truly?, unit

Methods inherited from Monad

#==, #bind, #fetch, #initialize, #join, #map, #to_s, unit

Constructor Details

This class inherits a constructor from Monadic::Monad

Class Method Details

.fetch(default = nil) ⇒ Object Also known as: _



48
49
50
51
# File 'lib/monadic/maybe.rb', line 48

def fetch(default=nil)
  return self if default.nil?
  return default
end

.method_missing(m, *args) ⇒ Object



54
55
56
# File 'lib/monadic/maybe.rb', line 54

def method_missing(m, *args)
  self
end

.to_aryObject Also known as: to_a



58
59
60
# File 'lib/monadic/maybe.rb', line 58

def to_ary
  []
end

.to_sObject



63
64
65
# File 'lib/monadic/maybe.rb', line 63

def to_s
  'Nothing'
end

.truly?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/monadic/maybe.rb', line 67

def truly?
  false
end