Class: Nothing

Inherits:
Maybe show all
Defined in:
lib/ruby-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/ruby-maybe/nothing.rb', line 2

def method_missing(method_name, *args, &block)
  Nothing.new
end

Instance Method Details

#==(object) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ruby-maybe/nothing.rb', line 22

def ==(object)
  if object.class == Nothing
    true
  else
    false
  end
end

#bindObject



6
7
8
# File 'lib/ruby-maybe/nothing.rb', line 6

def bind
  Nothing.new
end

#get(&block) ⇒ Object



18
19
20
# File 'lib/ruby-maybe/nothing.rb', line 18

def get(&block)
  block.call
end

#mapObject



10
11
12
# File 'lib/ruby-maybe/nothing.rb', line 10

def map
  Nothing.new
end

#or(&block) ⇒ Object



14
15
16
# File 'lib/ruby-maybe/nothing.rb', line 14

def or(&block)
  block.call
end