Class: Metro::SetupHandlers::GameExecution
- Inherits:
-
Object
- Object
- Metro::SetupHandlers::GameExecution
- 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
-
#output ⇒ Object
readonly
The output generated from the execution of code.
-
#parameters ⇒ Object
readonly
An array of parameters that will be provided to the execution of the game.
Class Method Summary collapse
-
.execute(parameters) ⇒ Object
Perform a game execution with the specified parameters and return the result of that game execution.
Instance Method Summary collapse
-
#execute! ⇒ Object
Perform the game execution.
-
#initialize(parameters) ⇒ GameExecution
constructor
A new instance of GameExecution.
-
#invalid? ⇒ TrueClass, FalseClass
True if the execution was a failure.
-
#status ⇒ Object
The status code that was returned when the game execution has completed.
-
#valid? ⇒ TrueClass, FalseClass
True if the execution was successful.
Constructor Details
#initialize(parameters) ⇒ GameExecution
Returns a new instance of GameExecution.
32 33 34 |
# File 'lib/setup_handlers/game_execution.rb', line 32 def initialize(parameters) @parameters = parameters end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the output generated from the execution of code.
22 23 24 |
# File 'lib/setup_handlers/game_execution.rb', line 22 def output @output end |
#parameters ⇒ Object (readonly)
Returns an array of parameters that will be provided to the execution of the game.
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
Returns true if the execution was a failure.
53 54 55 |
# File 'lib/setup_handlers/game_execution.rb', line 53 def invalid? status != 0 end |
#status ⇒ Object
Returns the status code that was returned when the game execution has completed.
38 39 40 |
# File 'lib/setup_handlers/game_execution.rb', line 38 def status @status ||= 0 end |
#valid? ⇒ TrueClass, FalseClass
Returns true if the execution was successful.
48 49 50 |
# File 'lib/setup_handlers/game_execution.rb', line 48 def valid? status == 0 end |