Class: Jobby::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(socket_path, &block) ⇒ Client

Creates a new client. Passing a block here is a shortcut for calling send and then close.



22
23
24
25
26
27
28
# File 'lib/client.rb', line 22

def initialize(socket_path, &block)
  @socket = UNIXSocket.open(socket_path)
  if block_given?
    yield(self)
    close
  end
end

Instance Method Details

#closeObject



34
35
36
# File 'lib/client.rb', line 34

def close
  @socket.close
end

#send(message = "") ⇒ Object



30
31
32
# File 'lib/client.rb', line 30

def send(message = "")
  @socket.send(message, 0)
end