Class: Ibex::Configuration::Explanation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(value, evidence:, recording:) ⇒ Explanation

Returns a new instance of Explanation.

RBS:

  • (Value value, evidence: Array[Evidence], recording: Recording) -> void

Parameters:



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

#evidenceArray[Evidence] (readonly)

Signature:

  • Array[Evidence]

Returns:



263
264
265
# File 'lib/ibex/configuration/explanation.rb', line 263

def evidence
  @evidence
end

#recordingRecording (readonly)

Signature:

  • Recording

Returns:



264
265
266
# File 'lib/ibex/configuration/explanation.rb', line 264

def recording
  @recording
end

#valueValue (readonly)

Signature:

  • Value

Returns:



262
263
264
# File 'lib/ibex/configuration/explanation.rb', line 262

def value
  @value
end

Instance Method Details

#to_hHash[String, json_value]

RBS:

  • () -> Hash[String, json_value]

Returns:

  • (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