Class: Maybe::Some
Constant Summary
Constants inherited
from Maybe
IsBlank
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Maybe
#>>, #apply!, #dig, #dig!, #map, #map!, #match, #none?, #of, of, #on_failure, #on_success, #or, #some?, #type, #unwrap
Constructor Details
#initialize(value = nil) ⇒ Some
113
114
115
|
# File 'lib/maybe.rb', line 113
def initialize(value = nil)
@value = value
end
|
Class Method Details
.[] ⇒ Object
109
110
111
|
# File 'lib/maybe.rb', line 109
def self.[](...)
new(...)
end
|
Instance Method Details
#>(other) ⇒ Object
129
130
131
|
# File 'lib/maybe.rb', line 129
def >(other)
other.respond_to?(:call) ? other.call(@value) : other
end
|
#deconstruct ⇒ Object
117
118
119
|
# File 'lib/maybe.rb', line 117
def deconstruct
[@value]
end
|
#fmap(&block) ⇒ Object
133
134
135
|
# File 'lib/maybe.rb', line 133
def fmap(&block)
Maybe[block.call(@value)]
end
|
#inspect ⇒ Object
121
122
123
|
# File 'lib/maybe.rb', line 121
def inspect
format("#<Zx::Maybe::#{self}:0x%x value=%s>", object_id, @value.inspect)
end
|
#to_s ⇒ Object
125
126
127
|
# File 'lib/maybe.rb', line 125
def to_s
'Some'
end
|