Class: Stupidedi::Reader::Failure
Instance Attribute Summary collapse
#reason
Instance Method Summary
collapse
Methods included from Result
#column, failure, #line, #offset, #position, success
#defined?, #explain, #fetch, #flatmap, #inspect, #map, #or, #reject, #select, #tap
Methods inherited from Either
#defined?, #explain, failure, #fetch, #flatmap, #map, #or, #reject, #select, success
Constructor Details
#initialize(reason, remainder, fatal) ⇒ Failure
119
120
121
122
|
# File 'lib/stupidedi/reader/result.rb', line 119
def initialize(reason, remainder, fatal)
@reason, @remainder, @fatal =
reason, remainder, fatal
end
|
Instance Attribute Details
#remainder ⇒ Object
Returns the value of attribute remainder.
117
118
119
|
# File 'lib/stupidedi/reader/result.rb', line 117
def remainder
@remainder
end
|
Instance Method Details
#==(other) ⇒ Boolean
141
142
143
144
145
146
147
|
# File 'lib/stupidedi/reader/result.rb', line 141
def ==(other)
if other.is_a?(self.class)
@reason == other.reason
else
@reason == other
end
end
|
#copy(changes = {}) ⇒ Failure
125
126
127
128
129
130
|
# File 'lib/stupidedi/reader/result.rb', line 125
def copy(changes = {})
Failure.new \
changes.fetch(:reason, @reason),
changes.fetch(:remainder, @remainder),
changes.fetch(:fatal, @fatal)
end
|
136
137
138
|
# File 'lib/stupidedi/reader/result.rb', line 136
def fatal
copy(:fatal => true)
end
|
#fatal? ⇒ Boolean
132
133
134
|
# File 'lib/stupidedi/reader/result.rb', line 132
def fatal?
@fatal
end
|
#pretty_print(q) ⇒ void
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/stupidedi/reader/result.rb', line 150
def pretty_print(q)
q.text "Result.failure"
q.group(2, "(", ")") do
q.breakable ""
q.pp @reason
q.text ","
q.breakable
q.pp @remainder
q.text ","
q.breakable
q.text "#{@fatal ? "" : "non-"}fatal"
end
end
|