Class: Nephos::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/nephos-server/server/main.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port = "8080", host = "0.0.0.0") ⇒ Server

Returns a new instance of Server.

Parameters:

  • port (Integer) (defaults to: "8080")

    port to listen



11
12
13
14
15
16
17
18
# File 'lib/nephos-server/server/main.rb', line 11

def initialize port="8080", host="0.0.0.0"
  @port = Integer(port)
  @host = host.to_s
  @server = lambda {|env|
    router = Router.new
    return router.execute(Rack::Request.new(env))
  }
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/nephos-server/server/main.rb', line 8

def host
  @host
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/nephos-server/server/main.rb', line 8

def port
  @port
end

Class Method Details

.start(port, host) ⇒ Object

start the Rack server on a instance of Nephos::Server



26
27
28
# File 'lib/nephos-server/server/main.rb', line 26

def self.start port, host
  Server.new(port, host).start
end

Instance Method Details

#startObject

start the Rack server



21
22
23
# File 'lib/nephos-server/server/main.rb', line 21

def start
  Rack::Server.start :app => @server, :Port => @port, :Host => @host
end