Class: Kamerling::Server::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/kamerling/server/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addr:) ⇒ HTTP

Returns a new instance of HTTP.



9
10
11
# File 'lib/kamerling/server/http.rb', line 9

def initialize(addr:)
  @addr = addr
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



7
8
9
# File 'lib/kamerling/server/http.rb', line 7

def addr
  @addr
end

Instance Method Details

#joinObject



13
14
15
# File 'lib/kamerling/server/http.rb', line 13

def join
  thread.join
end

#startObject



17
18
19
20
21
22
23
# File 'lib/kamerling/server/http.rb', line 17

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

#stopObject



25
26
27
# File 'lib/kamerling/server/http.rb', line 25

def stop
  thread.exit.join
end