Class: Lemans::Result::Outcome
- Inherits:
-
Object
- Object
- Lemans::Result::Outcome
- 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
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#scored ⇒ Object
(also: #scored?)
readonly
Returns the value of attribute scored.
-
#status ⇒ Object
(also: #name)
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(status, detail = nil) ⇒ Outcome
constructor
A new instance of Outcome.
- #invalid? ⇒ Boolean
Constructor Details
#initialize(status, detail = nil) ⇒ Outcome
Returns a new instance of Outcome.
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
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
22 23 24 |
# File 'lib/lemans/result.rb', line 22 def detail @detail end |
#scored ⇒ Object (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 |
#status ⇒ Object (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_json ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/lemans/result.rb', line 40 def as_json(**) { name:, scored:, detail: }.compact end |
#invalid? ⇒ Boolean
38 |
# File 'lib/lemans/result.rb', line 38 def invalid? = !scored |