Class: Hokusai::Automation::Client::Block

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid, client) ⇒ Block

Returns a new instance of Block.



25
26
27
28
# File 'ui/src/hokusai/automation/client.rb', line 25

def initialize(uuid, client)
  @uuid = uuid
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'ui/src/hokusai/automation/client.rb', line 10

def client
  @client
end

#uuidObject (readonly)

Returns the value of attribute uuid.



10
11
12
# File 'ui/src/hokusai/automation/client.rb', line 10

def uuid
  @uuid
end

Class Method Details

.locate(selector, client) ⇒ Object



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

def self.locate(selector, client)
  value = client.make_request("commands/locate", { selector: selector })
  new(value, client)
end

.locate_all(selector, client) ⇒ Object



17
18
19
20
21
22
23
# File 'ui/src/hokusai/automation/client.rb', line 17

def self.locate_all(selector, client)
  value = client.make_request("commands/locate", { selector: selector })

  value.map do |val|
    new(val, client)
  end
end

Instance Method Details

#clickObject



40
41
42
# File 'ui/src/hokusai/automation/client.rb', line 40

def click
  left_click
end

#drag_to(x, y) ⇒ Object



60
61
62
# File 'ui/src/hokusai/automation/client.rb', line 60

def drag_to(x, y)
  client.make_request("commands/drag", {uuid: uuid, x: x, y: y})
end

#hoverObject



56
57
58
# File 'ui/src/hokusai/automation/client.rb', line 56

def hover
  client.make_request("commands/hover", { uuid: uuid })
end

#invoke(name) ⇒ Object



52
53
54
# File 'ui/src/hokusai/automation/client.rb', line 52

def invoke(name)
  client.make_request("commands/invoke", {uuid: uuid, method: name})
end

#mouseupObject



44
45
46
# File 'ui/src/hokusai/automation/client.rb', line 44

def mouseup
  left_mouseup
end

#prop(name) ⇒ Object



48
49
50
# File 'ui/src/hokusai/automation/client.rb', line 48

def prop(name)
  client.make_request("commands/attribute", { uuid: uuid, attribute_name: name})
end

#scroll(to) ⇒ Object



75
76
77
# File 'ui/src/hokusai/automation/client.rb', line 75

def scroll(to)
  client.make_request("commands/wheel", {id: uuid, scroll_amount: to})
end

#send_keys(keys) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'ui/src/hokusai/automation/client.rb', line 64

def send_keys(keys)
  case keys
  when String
    encoded = KeysTranscoder.encode(keys.chars)
  else
    encoded = KeysTranscoder.encode(keys)
  end

  client.make_request("commands/keyboard", {uuid: uuid, keys: encoded})
end