Class: Maybe::Something
- Inherits:
-
Object
show all
- Defined in:
- lib/maybe/something.rb
Instance Method Summary
collapse
Constructor Details
#initialize(value) ⇒ Something
Returns a new instance of Something.
3
4
5
|
# File 'lib/maybe/something.rb', line 3
def initialize(value)
@value = value
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object
26
27
28
|
# File 'lib/maybe/something.rb', line 26
def method_missing(method, *args, &blk)
Maybe(value.send(method, *args, &blk))
end
|
Instance Method Details
#get ⇒ Object
Also known as:
else
7
8
9
|
# File 'lib/maybe/something.rb', line 7
def get
value
end
|
#if_something(&blk) ⇒ Object
13
14
15
16
|
# File 'lib/maybe/something.rb', line 13
def if_something(&blk)
blk.(value)
self
end
|
#nothing? ⇒ Boolean
18
19
20
|
# File 'lib/maybe/something.rb', line 18
def nothing?
false
end
|
#something? ⇒ Boolean
22
23
24
|
# File 'lib/maybe/something.rb', line 22
def something?
true
end
|