Class: Nr

Inherits:
Object
  • Object
show all
Includes:
Celluloid::IO
Defined in:
lib/nr.rb,
lib/nr/version.rb

Defined Under Namespace

Modules: Runner

Constant Summary collapse

VERSION =
'0.9.1'

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ Nr

Returns a new instance of Nr.



7
8
9
# File 'lib/nr.rb', line 7

def initialize host, port
  @server = TCPServer.new(host, port)
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/nr.rb', line 11

def start
  sock = @server.accept
  loop{ yield sock.readpartial(4096) }
rescue EOFError
  begin
    sock.close
  rescue EOFError
  end
  terminate
end