Class: Metro::SetupHandlers::GameExecution

Inherits:
Object
  • Object
show all
Defined in:
lib/setup_handlers/game_execution.rb

Overview

The GameExecution allows for a game to be executed. This is used by Metro to validate that the code can be loaded and run before actually running it (specifically when reloading live running code)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ GameExecution



32
33
34
# File 'lib/setup_handlers/game_execution.rb', line 32

def initialize(parameters)
  @parameters = parameters
end

Instance Attribute Details

#outputObject (readonly)



22
23
24
# File 'lib/setup_handlers/game_execution.rb', line 22

def output
  @output
end

#parametersObject (readonly)



26
27
28
# File 'lib/setup_handlers/game_execution.rb', line 26

def parameters
  @parameters
end

Class Method Details

.execute(parameters) ⇒ Object

Perform a game execution with the specified parameters and return the result of that game execution.



15
16
17
18
19
# File 'lib/setup_handlers/game_execution.rb', line 15

def self.execute(parameters)
  execution = new(parameters)
  execution.execute!
  execution
end

Instance Method Details

#execute!Object

Perform the game execution.



43
44
45
# File 'lib/setup_handlers/game_execution.rb', line 43

def execute!
  @output, @status = Open3.capture2e(game_execution_string)
end

#invalid?TrueClass, FalseClass



53
54
55
# File 'lib/setup_handlers/game_execution.rb', line 53

def invalid?
  status != 0
end

#statusObject



38
39
40
# File 'lib/setup_handlers/game_execution.rb', line 38

def status
  @status ||= 0
end

#valid?TrueClass, FalseClass



48
49
50
# File 'lib/setup_handlers/game_execution.rb', line 48

def valid?
  status == 0
end