Class: Lemans::Result::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/lemans/result.rb

Overview

:nodoc:

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 pending harness_crash].freeze
ALL =
(SCORED + INVALID).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, detail = nil) ⇒ Outcome

Returns a new instance of Outcome.

Raises:



29
30
31
32
33
34
35
36
# File 'lib/lemans/result.rb', line 29

def initialize(status, detail = nil)
  status = status.to_sym
  raise IncompatibleError, "Unrecognized outcome: #{status}" unless ALL.include?(status)

  @status = status
  @detail = detail
  @scored = SCORED.include?(status)
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



22
23
24
# File 'lib/lemans/result.rb', line 22

def detail
  @detail
end

#scoredObject (readonly) Also known as: scored?

Returns the value of attribute scored.



22
23
24
# File 'lib/lemans/result.rb', line 22

def scored
  @scored
end

#statusObject (readonly) Also known as: name

Returns the value of attribute status.



22
23
24
# File 'lib/lemans/result.rb', line 22

def status
  @status
end

Class Method Details

.from_json(data) ⇒ Object



48
49
50
51
# File 'lib/lemans/result.rb', line 48

def self.from_json(data)
  status, detail = data.values_at(:name, :detail)
  new(status, detail)
end

Instance Method Details

#as_jsonObject



40
41
42
43
44
45
46
# File 'lib/lemans/result.rb', line 40

def as_json(**)
  {
    name:,
    scored:,
    detail:
  }.compact
end

#invalid?Boolean

Returns:

  • (Boolean)


38
# File 'lib/lemans/result.rb', line 38

def invalid? = !scored