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 ⇒ Object
readonly
Returns the value of attribute remainder.
Attributes inherited from Either::Failure
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #copy(changes = {}) ⇒ Failure
- #fatal ⇒ Object
- #fatal? ⇒ Boolean
-
#initialize(reason, remainder, fatal) ⇒ Failure
constructor
A new instance of Failure.
- #pretty_print(q) ⇒ void
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.
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 (readonly)
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 |
#fatal ⇒ Object
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
This method returns an undefined value.
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 |