Class: HAStats::Socket

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket_addr) ⇒ Socket

Returns a new instance of Socket.



5
6
7
# File 'lib/hastats/socket.rb', line 5

def initialize(socket_addr)
  @socket_addr = socket_addr
end

Instance Attribute Details

#socket_addrObject

Returns the value of attribute socket_addr.



3
4
5
# File 'lib/hastats/socket.rb', line 3

def socket_addr
  @socket_addr
end

Instance Method Details

#run(cmd) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/hastats/socket.rb', line 9

def run(cmd)
  result = ""
  UNIXSocket.open(socket_addr) do |socket|
    socket.write("#{cmd};")
    while out = socket.gets
      result += out
    end
  end
  result
end