Class: Ytry::Success
- Inherits:
-
Object
show all
- Includes:
- Try
- Defined in:
- lib/ytry.rb
Instance Method Summary
collapse
Methods included from Try
ary_to_type, #each, #flat_map, #flatten, #get_or_else, #grep, #inspect, #map, #on_failure, #or_else, #reject, #select, zip, #zip, #|
Constructor Details
#initialize(value) ⇒ Success
Returns a new instance of Success.
101
102
103
|
# File 'lib/ytry.rb', line 101
def initialize value
@value = value.freeze
end
|
Instance Method Details
#==(other) ⇒ Object
108
109
110
|
# File 'lib/ytry.rb', line 108
def == other
other.is_a?(Success) && self.get == other.get
end
|
#===(other) ⇒ Object
111
112
113
|
# File 'lib/ytry.rb', line 111
def === other
other.is_a?(Success) && self.get === other.get
end
|
#empty? ⇒ Boolean
105
|
# File 'lib/ytry.rb', line 105
def empty?() false end
|
#get ⇒ Object
104
|
# File 'lib/ytry.rb', line 104
def get() @value end
|
#recover(&block) ⇒ Object
114
115
116
117
|
# File 'lib/ytry.rb', line 114
def recover &block
raise ArgumentError, 'missing block' unless block_given?
self
end
|
#recover_with(&block) ⇒ Object
118
119
120
121
|
# File 'lib/ytry.rb', line 118
def recover_with &block
raise ArgumentError, 'missing block' unless block_given?
self
end
|
#to_ary ⇒ Object
107
|
# File 'lib/ytry.rb', line 107
def to_ary() [get] end
|
#to_s ⇒ Object
106
|
# File 'lib/ytry.rb', line 106
def to_s() "Success(#{get})" end
|