Class: Monadic::Nothing
Overview
Represents a NullObject
Class Method Summary collapse
- .===(other) ⇒ Object
- .empty? ⇒ Boolean
-
.fetch(default = nil) ⇒ Object
(also: _)
The default value passed.
- .method_missing(m, *args) ⇒ Object
-
.or(other) ⇒ Object
An alternative value, the passed value is coerced into Maybe, thus Nothing.or(1) will be Just(1).
-
.to_ary ⇒ Object
(also: to_a)
def respond_to? end.
- .to_json(*args) ⇒ Object
- .to_s(*args) ⇒ Object
- .truly? ⇒ Boolean
Methods inherited from Maybe
#empty?, #select, #truly?, unit
Methods included from Monad
#==, #bind, #fetch, #flat_map, #initialize, #join, #map, #to_ary, #to_s
Class Method Details
.===(other) ⇒ Object
116 117 118 |
# File 'lib/monadic/maybe.rb', line 116 def ===(other) other == Nothing end |
.empty? ⇒ Boolean
112 113 114 |
# File 'lib/monadic/maybe.rb', line 112 def empty? true end |
.fetch(default = nil) ⇒ Object Also known as: _
Returns the default value passed.
77 78 79 80 |
# File 'lib/monadic/maybe.rb', line 77 def fetch(default=nil) return self if default.nil? return default end |
.method_missing(m, *args) ⇒ Object
83 84 85 |
# File 'lib/monadic/maybe.rb', line 83 def method_missing(m, *args) self end |
.or(other) ⇒ Object
Returns an alternative value, the passed value is coerced into Maybe, thus Nothing.or(1) will be Just(1).
88 89 90 |
# File 'lib/monadic/maybe.rb', line 88 def or(other) Maybe.unit(other) end |
.to_ary ⇒ Object Also known as: to_a
def respond_to? end
95 96 97 |
# File 'lib/monadic/maybe.rb', line 95 def to_ary [] end |
.to_json(*args) ⇒ Object
104 105 106 |
# File 'lib/monadic/maybe.rb', line 104 def to_json(*args) 'null' end |
.to_s(*args) ⇒ Object
100 101 102 |
# File 'lib/monadic/maybe.rb', line 100 def to_s(*args) 'Nothing' end |
.truly? ⇒ Boolean
108 109 110 |
# File 'lib/monadic/maybe.rb', line 108 def truly? false end |