Class: RFunk::Some
Instance Attribute Summary collapse
-
#value ⇒ Object
(also: #identity)
readonly
Returns the value of attribute value.
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Option
inherited
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
15
16
17
|
# File 'lib/rfunk/maybe/some.rb', line 15
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
30
31
32
|
# File 'lib/rfunk/maybe/some.rb', line 30
def method_missing(method, *arguments, &block)
RFunk.option(value.send(method, *arguments, &block))
end
|
Instance Attribute Details
#value ⇒ Object
Also known as:
identity
Returns the value of attribute value.
13
14
15
|
# File 'lib/rfunk/maybe/some.rb', line 13
def value
@value
end
|
Class Method Details
.create(value) ⇒ Object
4
5
6
|
# File 'lib/rfunk/maybe/some.rb', line 4
def create(value)
new(value)
end
|
.satisfies?(value) ⇒ Boolean
8
9
10
|
# File 'lib/rfunk/maybe/some.rb', line 8
def satisfies?(value)
!value.nil?
end
|
Instance Method Details
#<=>(other) ⇒ Object
38
39
40
|
# File 'lib/rfunk/maybe/some.rb', line 38
def <=>(other)
value <=> other.value
end
|
#==(other) ⇒ Object
34
35
36
|
# File 'lib/rfunk/maybe/some.rb', line 34
def ==(other)
value == other.value
end
|
#coerce(other) ⇒ Object
42
43
44
|
# File 'lib/rfunk/maybe/some.rb', line 42
def coerce(other)
[other, value]
end
|
#key ⇒ Object
48
49
50
|
# File 'lib/rfunk/maybe/some.rb', line 48
def key
:some
end
|
#or(_) ⇒ Object
21
22
23
|
# File 'lib/rfunk/maybe/some.rb', line 21
def or(_)
self
end
|
#pipe(&block) ⇒ Object
25
26
27
28
|
# File 'lib/rfunk/maybe/some.rb', line 25
def pipe(&block)
return self if block.nil?
RFunk.option(yield value)
end
|