Class: Lackie::RemoteControl
- Inherits:
-
Object
- Object
- Lackie::RemoteControl
- Defined in:
- lib/lackie/remote_control.rb
Instance Method Summary collapse
- #await(expression, options = {}) ⇒ Object
- #exec(command, options = {}) ⇒ Object
-
#initialize(host, port, poller = Poller.new) ⇒ RemoteControl
constructor
A new instance of RemoteControl.
- #log(message) ⇒ Object
Constructor Details
#initialize(host, port, poller = Poller.new) ⇒ RemoteControl
Returns a new instance of RemoteControl.
8 9 10 |
# File 'lib/lackie/remote_control.rb', line 8 def initialize(host, port, poller=Poller.new) @host, @port, @poller = host, port, poller end |
Instance Method Details
#await(expression, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lackie/remote_control.rb', line 21 def await(expression, ={}) result = nil begin @poller.await("result matching expression: #{expression}", ) do begin result = exec(expression) rescue TimeoutError => e end yield result end rescue TimeoutError => e raise AwaitError.new(expression, result) end result end |
#exec(command, options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/lackie/remote_control.rb', line 16 def exec(command, ={}) send_command(command) poll_for_result(command, ) end |
#log(message) ⇒ Object
12 13 14 |
# File 'lib/lackie/remote_control.rb', line 12 def log() exec("Lackie.log(#{.to_json})") end |