Class: Hokusai::Automation::Driver

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/automation/driver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDriver

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

#queueObject (readonly)

Returns the value of attribute queue.



12
13
14
# File 'ui/src/hokusai/automation/driver.rb', line 12

def queue
  @queue
end

#resultsObject (readonly)

Returns the value of attribute results.



12
13
14
# File 'ui/src/hokusai/automation/driver.rb', line 12

def results
  @results
end

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

#completeObject



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

#stopObject



24
25
26
# File 'ui/src/hokusai/automation/driver.rb', line 24

def stop
  @server.stop
end