Class: EasyMonads::Option::None
Instance Method Summary
collapse
Methods inherited from Monadic
#bind_unit, #data, #unit, unit
Constructor Details
#initialize(*args) ⇒ None
Returns a new instance of None.
14
15
16
|
# File 'lib/easy_monads/option.rb', line 14
def initialize(*args)
@data = nil
end
|
Instance Method Details
#<=>(other_monad) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/easy_monads/option.rb', line 29
def <=>(other_monad)
if self == other_monad
0
else
raise RuntimeError.new("#{self.class.name} is not comparable to other types") end
end
|
#==(other_monad) ⇒ Object
25
26
27
|
# File 'lib/easy_monads/option.rb', line 25
def ==(other_monad)
other_monad.is_a? self.class
end
|
#bind ⇒ Object
18
19
20
|
# File 'lib/easy_monads/option.rb', line 18
def bind
self
end
|
#defined? ⇒ Boolean
45
46
47
|
# File 'lib/easy_monads/option.rb', line 45
def defined?
false
end
|
#each ⇒ Object
22
23
|
# File 'lib/easy_monads/option.rb', line 22
def each
end
|
#empty? ⇒ Boolean
57
58
59
|
# File 'lib/easy_monads/option.rb', line 57
def empty?
true
end
|
#exists?(&pred) ⇒ Boolean
41
42
43
|
# File 'lib/easy_monads/option.rb', line 41
def exists?(&pred)
false
end
|
#get_or_else(else_val = nil) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/easy_monads/option.rb', line 49
def get_or_else(else_val=nil)
if block_given?
yield
else
else_val
end
end
|
#or_else ⇒ Object
61
62
63
|
# File 'lib/easy_monads/option.rb', line 61
def or_else
yield
end
|
#size ⇒ Object
37
38
39
|
# File 'lib/easy_monads/option.rb', line 37
def size
0
end
|