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
36
37
38
|
# File 'lib/rfunk/maybe/some.rb', line 36
def <=>(other)
value <=> other.value
end
|
#==(other) ⇒ Object
30
31
32
33
34
|
# File 'lib/rfunk/maybe/some.rb', line 30
def ==(other)
return false unless self.class == other.class
value == other.value
end
|
#coerce(other) ⇒ Object
40
41
42
|
# File 'lib/rfunk/maybe/some.rb', line 40
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
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
26
27
28
|
# File 'lib/rfunk/maybe/some.rb', line 26
def respond_to_missing?(method_name, include_private = false)
value.respond_to_missing?(method_name, include_private)
end
|
#value(_ = RFunk::None()) ⇒ Object
9
10
11
|
# File 'lib/rfunk/maybe/some.rb', line 9
def value(_ = RFunk::None())
@value
end
|