Class: Lemans::Results::Outcome
- Inherits:
-
Object
- Object
- Lemans::Results::Outcome
- Defined in:
- lib/lemans/results/outcome.rb
Overview
Why a trial ended, and whether its reward means anything: out-of-budget is a scored failure, a sandbox that never started measured nothing.
Constant Summary collapse
- SCORED =
%i[completed agent_timeout step_limit_reached cost_ceiling_reached].freeze
- INVALID =
%i[environment_error agent_error accounting_error verifier_error cancelled harness_crash].freeze
- ALL =
(SCORED + INVALID).freeze
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, detail: nil) ⇒ Outcome
constructor
A new instance of Outcome.
- #invalid? ⇒ Boolean
- #scored? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, detail: nil) ⇒ Outcome
Returns a new instance of Outcome.
15 16 17 18 19 20 21 |
# File 'lib/lemans/results/outcome.rb', line 15 def initialize(name, detail: nil) raise ArgumentError, "unknown outcome #{name.inspect}" unless ALL.include?(name) @name = name @detail = detail freeze end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
13 14 15 |
# File 'lib/lemans/results/outcome.rb', line 13 def detail @detail end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/lemans/results/outcome.rb', line 13 def name @name end |
Instance Method Details
#invalid? ⇒ Boolean
29 |
# File 'lib/lemans/results/outcome.rb', line 29 def invalid? = !scored? |
#scored? ⇒ Boolean
27 |
# File 'lib/lemans/results/outcome.rb', line 27 def scored? = SCORED.include?(name) |
#to_h ⇒ Object
31 |
# File 'lib/lemans/results/outcome.rb', line 31 def to_h = { name: name, scored: scored?, detail: detail }.compact |
#to_s ⇒ Object
33 |
# File 'lib/lemans/results/outcome.rb', line 33 def to_s = detail ? "#{name}: #{detail}" : name.to_s |