Class: Simmer::Externals::SpoonClient::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/simmer/externals/spoon_client/result.rb

Overview

The return object from a SpoonClient#run call.

Instance Attribute Summary collapse

Instance Method Summary collapse

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          = message
  @execution_result = execution_result
  @time_in_seconds  = (time_in_seconds || 0).round(2)

  freeze
end

Instance Attribute Details

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

#messageObject (readonly)

Returns the value of attribute message.



15
16
17
# File 'lib/simmer/externals/spoon_client/result.rb', line 15

def message
  @message
end

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

Returns:

  • (Boolean)


29
30
31
# File 'lib/simmer/externals/spoon_client/result.rb', line 29

def fail?
  !pass?
end

#pass?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/simmer/externals/spoon_client/result.rb', line 25

def pass?
  execution_result.code.zero?
end

#to_hObject



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' => message,
    'execution_result' => {
      'args' => execution_result.args,
      'code' => execution_result.code,
      'pid' => execution_result.pid
    },
    'time_in_seconds' => time_in_seconds
  }
end