Class: Nothing
- Inherits:
-
Maybe
show all
- Defined in:
- lib/matilda-maybe/nothing.rb
Instance Method Summary
collapse
Methods inherited from Maybe
from
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
2
3
4
|
# File 'lib/matilda-maybe/nothing.rb', line 2
def method_missing(method_name, *args, &block)
Nothing.new
end
|
Instance Method Details
#==(object) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/matilda-maybe/nothing.rb', line 30
def ==(object)
if object.class == Nothing
true
else
false
end
end
|
#bind ⇒ Object
6
7
8
|
# File 'lib/matilda-maybe/nothing.rb', line 6
def bind
Nothing.new
end
|
#get(*args, &block) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/matilda-maybe/nothing.rb', line 22
def get(*args, &block)
if args.empty?
block.call
else
args.first
end
end
|
#map ⇒ Object
10
11
12
|
# File 'lib/matilda-maybe/nothing.rb', line 10
def map
Nothing.new
end
|
#or(*args, &block) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/matilda-maybe/nothing.rb', line 14
def or(*args, &block)
if args.empty?
block.call
else
args.first
end
end
|