Class: Plux::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_name) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/plux/client.rb', line 5

def initialize(server_name)
  @server_name = server_name
  @writer = UNIXSocket.open(Plux.server_file(server_name))
end

Instance Attribute Details

#server_nameObject (readonly)

Returns the value of attribute server_name.



3
4
5
# File 'lib/plux/client.rb', line 3

def server_name
  @server_name
end

Instance Method Details

#closeObject



16
17
18
19
# File 'lib/plux/client.rb', line 16

def close
  puts(Parser::LAST_MSG)
  @writer.close
end

#puts(msg) ⇒ Object



10
11
12
13
14
# File 'lib/plux/client.rb', line 10

def puts(msg)
  Parser.encode(msg).each do |sub_msg|
    @writer.write(sub_msg)
  end
end