Class: Ibex::Configuration::Explanation
- Inherits:
-
Object
- Object
- Ibex::Configuration::Explanation
- Defined in:
- lib/ibex/configuration/explanation.rb,
sig/ibex/configuration/explanation.rbs
Overview
The effective value and all accepted or rejected evidence for one key.
Instance Attribute Summary collapse
- #evidence ⇒ Array[Evidence] readonly
- #recording ⇒ Recording readonly
- #value ⇒ Value readonly
Instance Method Summary collapse
-
#initialize(value, evidence:, recording:) ⇒ Explanation
constructor
A new instance of Explanation.
- #to_h ⇒ Hash[String, json_value]
Constructor Details
#initialize(value, evidence:, recording:) ⇒ Explanation
Returns a new instance of Explanation.
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/ibex/configuration/explanation.rb', line 267 def initialize(value, evidence:, recording:) raise ArgumentError, "explanation value must be a Configuration::Value" unless value.is_a?(Value) unless recording.is_a?(Recording) raise ArgumentError, "explanation recording must be a Configuration::Recording" end unless evidence.all? { |entry| entry.is_a?(Evidence) && entry.key.equal?(value.key) } raise ArgumentError, "explanation evidence has the wrong key" end @value = value @evidence = evidence.dup.freeze @recording = recording freeze end |
Instance Attribute Details
#evidence ⇒ Array[Evidence] (readonly)
263 264 265 |
# File 'lib/ibex/configuration/explanation.rb', line 263 def evidence @evidence end |
#recording ⇒ Recording (readonly)
264 265 266 |
# File 'lib/ibex/configuration/explanation.rb', line 264 def recording @recording end |
#value ⇒ Value (readonly)
262 263 264 |
# File 'lib/ibex/configuration/explanation.rb', line 262 def value @value end |
Instance Method Details
#to_h ⇒ Hash[String, json_value]
284 285 286 287 288 289 290 291 |
# File 'lib/ibex/configuration/explanation.rb', line 284 def to_h @value.to_h.merge( "selection" => @value.explicit ? "explicit" : "implicit", "conformance" => @value.canonical ? "canonical" : "noncanonical", "recording" => @recording.to_h, "evidence" => @evidence.map(&:to_h) ) end |