Class: HAStats::Socket
- Inherits:
-
Object
- Object
- HAStats::Socket
- Defined in:
- lib/hastats/socket.rb
Instance Attribute Summary collapse
-
#socket_addr ⇒ Object
Returns the value of attribute socket_addr.
Instance Method Summary collapse
-
#initialize(socket_addr) ⇒ Socket
constructor
A new instance of Socket.
- #run(cmd) ⇒ Object
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_addr ⇒ Object
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 |