lib/kamerling/server/http.rb in kamerling-0.0.2 vs lib/kamerling/server/http.rb in kamerling-0.0.3

- old
+ new

@@ -1,26 +1,33 @@ -module Kamerling module Server class HTTP - attr_reader :addr +require 'rack' +require_relative '../http_api' - def initialize addr: req(:addr) - @addr = addr - end +module Kamerling + module Server + class HTTP + attr_reader :addr - def join - thread.join - end + def initialize(addr:) + @addr = addr + end - def start - @thread = Thread.new do - Rack::Handler::WEBrick.run HTTPAPI, Host: addr.host, Port: addr.port - end - loop { break if addr.connectable? } - self - end + def join + thread.join + end - def stop - thread.exit.join - end + def start + @thread = Thread.new do + Rack::Handler::WEBrick.run HTTPAPI, Host: addr.host, Port: addr.port + end + loop { break if addr.connectable? } + self + end - attr_reader :thread - private :thread -end end end + def stop + thread.exit.join + end + + attr_reader :thread + private :thread + end + end +end