Class: Hokusai::Automation::DriverCommands::GetAttribute

Inherits:
Base
  • Object
show all
Defined in:
ui/src/hokusai/automation/driver_commands/get_attribute.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#last_parent, #request_id, #state, #status

Instance Method Summary collapse

Methods inherited from Base

#matches_block, #matches_blocks, #mouse_center, #mouse_move

Constructor Details

#initialize(state) ⇒ GetAttribute

Returns a new instance of GetAttribute.



6
7
8
9
10
# File 'ui/src/hokusai/automation/driver_commands/get_attribute.rb', line 6

def initialize(state)
  @value = nil

  super
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



4
5
6
# File 'ui/src/hokusai/automation/driver_commands/get_attribute.rb', line 4

def value
  @value
end

Instance Method Details

#attribute_nameObject



16
17
18
# File 'ui/src/hokusai/automation/driver_commands/get_attribute.rb', line 16

def attribute_name
  state[:attribute_name]
end

#execute(blocks, canvas, input) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'ui/src/hokusai/automation/driver_commands/get_attribute.rb', line 30

def execute(blocks, canvas, input)
  return unless matches_block(blocks[0])

  Log.debug { "Props: #{blocks[0].node.meta.props}".colorize(:yellow) }
  
  attribute = blocks[0].node.meta.props[attribute_name.to_sym]

  self.value = attribute
end

#locationObject



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

def location
  state[:uuid]
end

#on_completeObject



20
21
22
23
24
25
26
27
28
# File 'ui/src/hokusai/automation/driver_commands/get_attribute.rb', line 20

def on_complete
  done!

  if value.nil?
    return ::Hokusai::Automation::Error.new("Attribute #{attribute_name} not found")
  end

  return value
end