Class: Simmer::Externals::SpoonClient::Result
- Inherits:
-
Object
- Object
- Simmer::Externals::SpoonClient::Result
- Defined in:
- lib/simmer/externals/spoon_client/result.rb
Overview
The return object from a SpoonClient#run call.
Instance Attribute Summary collapse
-
#execution_result ⇒ Object
readonly
Returns the value of attribute execution_result.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#time_in_seconds ⇒ Object
readonly
Returns the value of attribute time_in_seconds.
Instance Method Summary collapse
- #fail? ⇒ Boolean
-
#initialize(message: '', execution_result:, time_in_seconds:) ⇒ Result
constructor
A new instance of Result.
- #pass? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(message: '', execution_result:, time_in_seconds:) ⇒ Result
Returns a new instance of Result.
17 18 19 20 21 22 23 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 17 def initialize(message: '', execution_result:, time_in_seconds:) @message = @execution_result = execution_result @time_in_seconds = (time_in_seconds || 0).round(2) freeze end |
Instance Attribute Details
#execution_result ⇒ Object (readonly)
Returns the value of attribute execution_result.
15 16 17 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 15 def execution_result @execution_result end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
15 16 17 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 15 def @message end |
#time_in_seconds ⇒ Object (readonly)
Returns the value of attribute time_in_seconds.
15 16 17 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 15 def time_in_seconds @time_in_seconds end |
Instance Method Details
#fail? ⇒ Boolean
29 30 31 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 29 def fail? !pass? end |
#pass? ⇒ Boolean
25 26 27 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 25 def pass? execution_result.code.zero? end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simmer/externals/spoon_client/result.rb', line 33 def to_h { 'pass' => pass?, 'message' => , 'execution_result' => { 'args' => execution_result.args, 'code' => execution_result.code, 'pid' => execution_result.pid }, 'time_in_seconds' => time_in_seconds } end |