Class: RFunk::Some
- Inherits:
-
Option
show all
- Extended by:
- Forwardable
- Defined in:
- lib/rfunk/maybe/some.rb
Instance Method Summary
collapse
Methods inherited from Option
#each
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
5
6
7
|
# File 'lib/rfunk/maybe/some.rb', line 5
def initialize(value)
@value = value
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
22
23
24
|
# File 'lib/rfunk/maybe/some.rb', line 22
def method_missing(method, *arguments, &block)
RFunk.option(value.send(method, *arguments, &block))
end
|
Instance Method Details
#<=>(other) ⇒ Object
31
32
33
|
# File 'lib/rfunk/maybe/some.rb', line 31
def <=>(other)
value <=> other.value
end
|
#==(other) ⇒ Object
26
27
28
29
|
# File 'lib/rfunk/maybe/some.rb', line 26
def ==(other)
return false unless self.class == other.class
value == RFunk.option(other).value
end
|
#coerce(other) ⇒ Object
35
36
37
|
# File 'lib/rfunk/maybe/some.rb', line 35
def coerce(other)
[other, value]
end
|
#or(_) ⇒ Object
13
14
15
|
# File 'lib/rfunk/maybe/some.rb', line 13
def or(_)
self
end
|
#pipe(&block) ⇒ Object
17
18
19
20
|
# File 'lib/rfunk/maybe/some.rb', line 17
def pipe(&block)
return self if block.nil?
RFunk.option(yield value)
end
|
#value(_ = RFunk.none) ⇒ Object
9
10
11
|
# File 'lib/rfunk/maybe/some.rb', line 9
def value(_ = RFunk.none)
@value
end
|