Class: Fear::Some
- Inherits:
-
Object
show all
- Includes:
- Option
- Defined in:
- lib/fear/some.rb
Constant Summary
collapse
proc do |option|
if Fear::Some === option
Fear.some([option.get])
else
Fear.none
end
end
Instance Method Summary
collapse
Methods included from Option
#any?, #each, #flat_map, #get_or_else, #include?, #map, match, #match, matcher, #or_else
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
18
19
20
|
# File 'lib/fear/some.rb', line 18
def initialize(value)
@value = value
end
|
Instance Method Details
#==(other) ⇒ Boolean
57
58
59
|
# File 'lib/fear/some.rb', line 57
def ==(other)
other.is_a?(Some) && get == other.get
end
|
#empty? ⇒ false
33
34
35
|
# File 'lib/fear/some.rb', line 33
def empty?
false
end
|
#get ⇒ any
23
24
25
|
# File 'lib/fear/some.rb', line 23
def get
@value
end
|
#inspect ⇒ String
Also known as:
to_s
62
63
64
|
# File 'lib/fear/some.rb', line 62
def inspect
"#<Fear::Some get=#{value.inspect}>"
end
|
#or_nil ⇒ any
28
29
30
|
# File 'lib/fear/some.rb', line 28
def or_nil
@value
end
|
47
48
49
50
51
52
53
|
# File 'lib/fear/some.rb', line 47
def reject
if yield(value)
None
else
self
end
end
|
38
39
40
41
42
43
44
|
# File 'lib/fear/some.rb', line 38
def select
if yield(value)
self
else
None
end
end
|