Class: Hokusai::Automation::Driver
- Inherits:
-
Object
- Object
- Hokusai::Automation::Driver
- Defined in:
- ui/src/hokusai/automation/driver.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #complete ⇒ Object
-
#execute(command) ⇒ Object
Adds a driver command to the queue to be executed.
-
#initialize ⇒ Driver
constructor
A new instance of Driver.
-
#process(blocks, canvas, input) ⇒ Object
Process a command with the given UI state.
- #serve(*args) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Driver
Returns a new instance of Driver.
14 15 16 17 18 |
# File 'ui/src/hokusai/automation/driver.rb', line 14 def initialize @queue = DriverCommandQueue.new @results = {} @server = Hokusai::Automation::Server end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
12 13 14 |
# File 'ui/src/hokusai/automation/driver.rb', line 12 def queue @queue end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
12 13 14 |
# File 'ui/src/hokusai/automation/driver.rb', line 12 def results @results end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
12 13 14 |
# File 'ui/src/hokusai/automation/driver.rb', line 12 def server @server end |
Instance Method Details
#complete ⇒ Object
28 29 30 |
# File 'ui/src/hokusai/automation/driver.rb', line 28 def complete queue.completed(results) end |
#execute(command) ⇒ Object
Adds a driver command to the queue to be executed
Commands process one-by-one on each iteration of the UI loop.
When a command is finished, its result will be populated in ‘#results`
38 39 40 |
# File 'ui/src/hokusai/automation/driver.rb', line 38 def execute(command) queue.commands << command end |
#process(blocks, canvas, input) ⇒ Object
Process a command with the given UI state
Results will added to the results hash and picked up by the current server request
-
‘blocks` is a tuple containing a block and its parent
-
‘canvas` is the current canvas being painted
-
‘input` is the application input state for this loop iteration
49 50 51 |
# File 'ui/src/hokusai/automation/driver.rb', line 49 def process(blocks, canvas, input) queue.process(blocks, canvas, input) end |
#serve(*args) ⇒ Object
20 21 22 |
# File 'ui/src/hokusai/automation/driver.rb', line 20 def serve(*args) @server.start(*args, driver: self) end |
#stop ⇒ Object
24 25 26 |
# File 'ui/src/hokusai/automation/driver.rb', line 24 def stop @server.stop end |