Module: XDo::Simulatable
- Defined in:
- lib/xdo/simulatable.rb
Overview
Mixin that allows String-like objects to be directly simulated. You can use it with Ruby’s String class:
require "xdo/simulatable"
class String
include XDo::Simulatable
def to_xdo
to_s
end
end
"abc".simulate
Every method in this module calls ##to_xdo on self
first, so make sure this method returns a xdo-usable String (i.e. no invisible characters except newline, tab and space).
Instance Method Summary collapse
-
#down(w_id = nil) ⇒ Object
Holds the first key of
self
down. -
#simulate(raw = false, w_id = nil) ⇒ Object
Simulates
self
as keystrokes. -
#type(w_id = nil) ⇒ Object
Types
self
as keystrokes. -
#up(w_id = nil) ⇒ Object
Releases the first key of
self
if it’s hold down by #down.
Instance Method Details
#down(w_id = nil) ⇒ Object
Holds the first key of self
down.
39 40 41 |
# File 'lib/xdo/simulatable.rb', line 39 def down(w_id = nil) XDo::Keyboard.key_down(to_xdo[0], w_id) end |
#simulate(raw = false, w_id = nil) ⇒ Object
Simulates self
as keystrokes. Escape sequences are allowed.
29 30 31 |
# File 'lib/xdo/simulatable.rb', line 29 def simulate(raw = false, w_id = nil) XDo::Keyboard.simulate(to_xdo, raw, w_id) end |