Class: Stupidedi::Reader::Failure
- Inherits:
-
Either::Failure
- Object
- Either
- Either::Failure
- Stupidedi::Reader::Failure
- Includes:
- Result
- Defined in:
- lib/stupidedi/reader/result.rb
Instance Attribute Summary collapse
-
#remainder
readonly
Returns the value of attribute remainder.
Attributes inherited from Either::Failure
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #copy(changes = {}) ⇒ Failure
- #fatal
- #fatal? ⇒ Boolean
-
#initialize(reason, remainder, fatal) ⇒ Failure
constructor
A new instance of Failure.
-
#pretty_print(q)
:nocov:.
Methods included from Result
#column, failure, #line, #offset, #position, success
Methods inherited from Either::Failure
#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
Returns a new instance of Failure.
118 119 120 121 |
# File 'lib/stupidedi/reader/result.rb', line 118 def initialize(reason, remainder, fatal) @reason, @remainder, @fatal = reason, remainder, fatal end |
Instance Attribute Details
#remainder (readonly)
Returns the value of attribute remainder.
116 117 118 |
# File 'lib/stupidedi/reader/result.rb', line 116 def remainder @remainder end |
Instance Method Details
#==(other) ⇒ Boolean
140 141 142 143 144 145 146 |
# File 'lib/stupidedi/reader/result.rb', line 140 def ==(other) if other.is_a?(self.class) @reason == other.reason else @reason == other end end |
#copy(changes = {}) ⇒ Failure
124 125 126 127 128 129 |
# File 'lib/stupidedi/reader/result.rb', line 124 def copy(changes = {}) Failure.new \ changes.fetch(:reason, @reason), changes.fetch(:remainder, @remainder), changes.fetch(:fatal, @fatal) end |
#fatal
135 136 137 |
# File 'lib/stupidedi/reader/result.rb', line 135 def fatal copy(:fatal => true) end |
#fatal? ⇒ Boolean
131 132 133 |
# File 'lib/stupidedi/reader/result.rb', line 131 def fatal? @fatal end |
#pretty_print(q)
This method returns an undefined value.
:nocov:
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 |