Class: Hokusai::Automation::Client::Block
- Inherits:
-
Object
- Object
- Hokusai::Automation::Client::Block
- Defined in:
- ui/src/hokusai/automation/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
- #click ⇒ Object
- #drag_to(x, y) ⇒ Object
- #hover ⇒ Object
-
#initialize(uuid, client) ⇒ Block
constructor
A new instance of Block.
- #invoke(name) ⇒ Object
- #mouseup ⇒ Object
- #prop(name) ⇒ Object
- #scroll(to) ⇒ Object
- #send_keys(keys) ⇒ Object
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
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'ui/src/hokusai/automation/client.rb', line 10 def client @client end |
#uuid ⇒ Object (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
#click ⇒ Object
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 |
#hover ⇒ Object
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 |
#mouseup ⇒ Object
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 |