Class: OrElse::Just
Instance Method Summary collapse
- #all? ⇒ Boolean
- #any?(&block) ⇒ Boolean
- #each {|value| ... } ⇒ Object
- #empty? ⇒ Boolean
- #exists? ⇒ Boolean
- #filter ⇒ Object
- #flat_map ⇒ Object
-
#initialize(val) ⇒ Just
constructor
A new instance of Just.
- #map ⇒ Object
- #or_else ⇒ Object
- #present? ⇒ Boolean
Methods inherited from Maybe
Constructor Details
#initialize(val) ⇒ Just
Returns a new instance of Just.
3 4 5 |
# File 'lib/or_else/just.rb', line 3 def initialize(val) @value = val end |
Instance Method Details
#all? ⇒ Boolean
40 41 42 |
# File 'lib/or_else/just.rb', line 40 def all? !!(yield value) end |
#any?(&block) ⇒ Boolean
44 45 46 |
# File 'lib/or_else/just.rb', line 44 def any?(&block) all?(&block) end |
#each {|value| ... } ⇒ Object
35 36 37 38 |
# File 'lib/or_else/just.rb', line 35 def each yield value nil end |
#empty? ⇒ Boolean
19 20 21 |
# File 'lib/or_else/just.rb', line 19 def empty? false end |
#exists? ⇒ Boolean
23 24 25 |
# File 'lib/or_else/just.rb', line 23 def exists? !empty? end |
#filter ⇒ Object
15 16 17 |
# File 'lib/or_else/just.rb', line 15 def filter (yield value) ? self : Nothing end |
#flat_map ⇒ Object
11 12 13 |
# File 'lib/or_else/just.rb', line 11 def flat_map Maybe(yield value) end |
#map ⇒ Object
7 8 9 |
# File 'lib/or_else/just.rb', line 7 def map Just(yield value) end |
#or_else ⇒ Object
31 32 33 |
# File 'lib/or_else/just.rb', line 31 def or_else value end |
#present? ⇒ Boolean
27 28 29 |
# File 'lib/or_else/just.rb', line 27 def present? exists? end |