Class: Jimson::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, host = '0.0.0.0', port = 8999, logger = Logger.new(STDOUT)) ⇒ Server

Returns a new instance of Server.



147
148
149
150
151
152
# File 'lib/jimson/server.rb', line 147

def initialize(handler, host = '0.0.0.0', port = 8999, logger = Logger.new(STDOUT))
  @handler = handler
  @host = host
  @port = port
  @logger = logger
end

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



145
146
147
# File 'lib/jimson/server.rb', line 145

def handler
  @handler
end

#hostObject

Returns the value of attribute host.



145
146
147
# File 'lib/jimson/server.rb', line 145

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



145
146
147
# File 'lib/jimson/server.rb', line 145

def logger
  @logger
end

#portObject

Returns the value of attribute port.



145
146
147
# File 'lib/jimson/server.rb', line 145

def port
  @port
end

Instance Method Details

#startObject



154
155
156
157
158
159
160
# File 'lib/jimson/server.rb', line 154

def start
  Jimson::HttpServer.handler = @handler
  EM.run do
    EM::start_server(@host, @port, Jimson::HttpServer)
    @logger.info("Server listening on #{@host}:#{@port} with handler '#{@handler}'")
  end
end