Class: Simmer::Runner::Result
- Inherits:
-
Object
- Object
- Simmer::Runner::Result
- Extended by:
- Forwardable
- Defined in:
- lib/simmer/runner/result.rb
Overview
Return object from a Runner#run call.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#judge_result ⇒ Object
readonly
Returns the value of attribute judge_result.
-
#specification ⇒ Object
readonly
Returns the value of attribute specification.
-
#spoon_client_result ⇒ Object
readonly
Returns the value of attribute spoon_client_result.
Instance Method Summary collapse
- #fail? ⇒ Boolean
-
#initialize(id:, specification:, judge_result: nil, spoon_client_result: nil, errors: []) ⇒ Result
constructor
A new instance of Result.
- #pass? ⇒ Boolean (also: #passing?)
- #time_in_seconds ⇒ Object
- #timed_out? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(id:, specification:, judge_result: nil, spoon_client_result: nil, errors: []) ⇒ Result
Returns a new instance of Result.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simmer/runner/result.rb', line 20 def initialize( id:, specification:, judge_result: nil, spoon_client_result: nil, errors: [] ) @id = id.to_s @judge_result = judge_result @specification = specification @spoon_client_result = spoon_client_result @errors = Array(errors) freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
16 17 18 |
# File 'lib/simmer/runner/result.rb', line 16 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/simmer/runner/result.rb', line 16 def id @id end |
#judge_result ⇒ Object (readonly)
Returns the value of attribute judge_result.
16 17 18 |
# File 'lib/simmer/runner/result.rb', line 16 def judge_result @judge_result end |
#specification ⇒ Object (readonly)
Returns the value of attribute specification.
16 17 18 |
# File 'lib/simmer/runner/result.rb', line 16 def specification @specification end |
#spoon_client_result ⇒ Object (readonly)
Returns the value of attribute spoon_client_result.
16 17 18 |
# File 'lib/simmer/runner/result.rb', line 16 def spoon_client_result @spoon_client_result end |
Instance Method Details
#fail? ⇒ Boolean
49 50 51 |
# File 'lib/simmer/runner/result.rb', line 49 def fail? !pass? end |
#pass? ⇒ Boolean Also known as: passing?
40 41 42 43 44 45 46 |
# File 'lib/simmer/runner/result.rb', line 40 def pass? [ judge_result&.pass?, spoon_client_result&.pass?, errors.empty?, ].all? end |
#time_in_seconds ⇒ Object
36 37 38 |
# File 'lib/simmer/runner/result.rb', line 36 def time_in_seconds spoon_client_result&.time_in_seconds || 0 end |
#timed_out? ⇒ Boolean
53 54 55 |
# File 'lib/simmer/runner/result.rb', line 53 def timed_out? errors.any? { |e| e.is_a?(Simmer::Runner::TimeoutError) } end |
#to_h ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/simmer/runner/result.rb', line 57 def to_h { 'name' => specification.name, 'id' => id, 'path' => specification.path, 'time_in_seconds' => time_in_seconds, 'pass' => pass?, 'spoon_client_result' => spoon_client_result.to_h, 'judge_result' => judge_result.to_h, 'errors' => errors.map(&:message), } end |