Class: Hokusai::Automation::DriverCommands::Locate
- Defined in:
- ui/src/hokusai/automation/driver_commands/locate.rb
Instance Attribute Summary collapse
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
Attributes inherited from Base
#last_parent, #request_id, #state, #status
Instance Method Summary collapse
- #execute(blocks, canvas, input) ⇒ Object
-
#initialize(hash) ⇒ Locate
constructor
A new instance of Locate.
- #on_complete ⇒ Object
- #selectors ⇒ Object
Methods inherited from Base
#matches_block, #matches_blocks, #mouse_center, #mouse_move
Constructor Details
#initialize(hash) ⇒ Locate
Returns a new instance of Locate.
8 9 10 11 12 13 |
# File 'ui/src/hokusai/automation/driver_commands/locate.rb', line 8 def initialize(hash) @matches = [] @selectors = nil super end |
Instance Attribute Details
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
6 7 8 |
# File 'ui/src/hokusai/automation/driver_commands/locate.rb', line 6 def matches @matches end |
Instance Method Details
#execute(blocks, canvas, input) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'ui/src/hokusai/automation/driver_commands/locate.rb', line 29 def execute(blocks, canvas, input) if selector = selectors.shift if selector.matches(blocks[0]) Log.debug {"Location match! #{selector}".colorize(:light_magenta)} portal = blocks[0].node.portal Log.debug { "uuid: #{portal.uuid.to_s}".colorize(:light_magenta) } matches << portal.uuid.to_s selectors.unshift(selector) if selectors.empty? else selectors.unshift(selector) end end end |
#on_complete ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'ui/src/hokusai/automation/driver_commands/locate.rb', line 15 def on_complete return if waiting? done! return ::Hokusai::Automation::Error.new("No matches found") if matches.empty? matches.last end |
#selectors ⇒ Object
25 26 27 |
# File 'ui/src/hokusai/automation/driver_commands/locate.rb', line 25 def selectors @selectors ||= Converters::SelectorConverter.parse_selectors(state[:selector]) end |