Class: Monad::Maybe::Nothing

Inherits:
Base show all
Includes:
Singleton
Defined in:
lib/monad/maybe/nothing.rb

Overview

A better nil

Instance Method Summary collapse

Methods inherited from Base

#<<, #maybe, #maybe?, #to_list

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



11
12
13
# File 'lib/monad/maybe/nothing.rb', line 11

def method_missing(method, *args)
  self
end

Instance Method Details

#cloneObject



15
16
17
# File 'lib/monad/maybe/nothing.rb', line 15

def clone
  self
end

#inspectObject



19
20
21
# File 'lib/monad/maybe/nothing.rb', line 19

def inspect
  'nothing'
end

#just?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/monad/maybe/nothing.rb', line 31

def just?
  false
end

#nil?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/monad/maybe/nothing.rb', line 23

def nil?
  true
end

#nothing?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/monad/maybe/nothing.rb', line 27

def nothing?
  true
end

#to_aObject



51
52
53
# File 'lib/monad/maybe/nothing.rb', line 51

def to_a
  []
end

#to_json(*args) ⇒ Object



43
44
45
# File 'lib/monad/maybe/nothing.rb', line 43

def to_json(*args)
  'null'
end

#to_sObject



47
48
49
# File 'lib/monad/maybe/nothing.rb', line 47

def to_s
  self
end

#unwrap(val) ⇒ Object



35
36
37
# File 'lib/monad/maybe/nothing.rb', line 35

def unwrap(val)
  val
end

#valueObject



39
40
41
# File 'lib/monad/maybe/nothing.rb', line 39

def value
  nil
end