Class: Druzy::Server::OneInstanceByPort

Inherits:
Object
  • Object
show all
Defined in:
lib/druzy/server/one_instance_by_port.rb

Direct Known Subclasses

RestrictedFileServer

Constant Summary collapse

@@instances =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ OneInstanceByPort

Returns a new instance of OneInstanceByPort.



8
9
10
# File 'lib/druzy/server/one_instance_by_port.rb', line 8

def initialize(port)
  @server=WEBrick::HTTPServer.new(:Port => port, :AccessLog => [], :Logger => WEBrick::Log.new(File::NULL))
end

Class Method Details

.instance(port) ⇒ Object



12
13
14
15
16
17
# File 'lib/druzy/server/one_instance_by_port.rb', line 12

def self.instance(port)
  if !@@instances.has_key?(port)
    @@instances[port]=new(port)
  end
  @@instances[port]
end