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.
20
21
22
|
# File 'lib/fear/some.rb', line 20
def initialize(value)
@value = value
end
|
Instance Method Details
#==(other) ⇒ Boolean
59
60
61
|
# File 'lib/fear/some.rb', line 59
def ==(other)
other.is_a?(Some) && get == other.get
end
|
#empty? ⇒ false
35
36
37
|
# File 'lib/fear/some.rb', line 35
def empty?
false
end
|
#get ⇒ any
25
26
27
|
# File 'lib/fear/some.rb', line 25
def get
@value
end
|
#inspect ⇒ String
Also known as:
to_s
64
65
66
|
# File 'lib/fear/some.rb', line 64
def inspect
"#<Fear::Some get=#{value.inspect}>"
end
|
#or_nil ⇒ any
30
31
32
|
# File 'lib/fear/some.rb', line 30
def or_nil
@value
end
|
49
50
51
52
53
54
55
|
# File 'lib/fear/some.rb', line 49
def reject
if yield(value)
None
else
self
end
end
|
40
41
42
43
44
45
46
|
# File 'lib/fear/some.rb', line 40
def select
if yield(value)
self
else
None
end
end
|