Class: Lackie::RemoteControl

Inherits:
Object
  • Object
show all
Defined in:
lib/lackie/remote_control.rb

Instance Method Summary collapse

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, options={})
  result = nil
  begin
    @poller.await("result matching expression: #{expression}", options) 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, options={})
  send_command(command)
  poll_for_result(command, options)
end

#log(message) ⇒ Object



12
13
14
# File 'lib/lackie/remote_control.rb', line 12

def log(message)
  exec("Lackie.log(#{message.to_json})")
end