Class: Lemans::Results::Outcome

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

Instance Method Summary collapse

Constructor Details

#initialize(name, detail: nil) ⇒ Outcome

Returns a new instance of Outcome.

Raises:

  • (ArgumentError)


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

#detailObject (readonly)

Returns the value of attribute detail.



13
14
15
# File 'lib/lemans/results/outcome.rb', line 13

def detail
  @detail
end

#nameObject (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

Returns:

  • (Boolean)


29
# File 'lib/lemans/results/outcome.rb', line 29

def invalid? = !scored?

#scored?Boolean

Returns:

  • (Boolean)


27
# File 'lib/lemans/results/outcome.rb', line 27

def scored? = SCORED.include?(name)

#to_hObject



31
# File 'lib/lemans/results/outcome.rb', line 31

def to_h = { name: name, scored: scored?, detail: detail }.compact

#to_sObject



33
# File 'lib/lemans/results/outcome.rb', line 33

def to_s = detail ? "#{name}: #{detail}" : name.to_s