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
17
18
19
|
# File 'lib/rfunk/maybe/some.rb', line 17
def method_missing(method, *arguments, &block)
Option(value.send(method, *arguments, &block))
end
|
Instance Method Details
#<=>(other) ⇒ Object
27
28
29
|
# File 'lib/rfunk/maybe/some.rb', line 27
def <=>(other)
value <=> other.value
end
|
#==(other) ⇒ Object
21
22
23
24
25
|
# File 'lib/rfunk/maybe/some.rb', line 21
def ==(other)
return false unless self.class == other.class
value == other.value
end
|
#coerce(other) ⇒ Object
31
32
33
|
# File 'lib/rfunk/maybe/some.rb', line 31
def coerce(other)
[other, value]
end
|
#or(_) ⇒ Object
13
14
15
|
# File 'lib/rfunk/maybe/some.rb', line 13
def or(_)
self
end
|
#value(_ = None()) ⇒ Object
9
10
11
|
# File 'lib/rfunk/maybe/some.rb', line 9
def value(_ = None())
@value
end
|