Class: Hi::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port = nil) ⇒ Server

Returns a new instance of Server.



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

def initialize(port = nil)
  @port = (port = port.to_i) > 0 ? port : 3000
end

Instance Attribute Details

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/hi/server.rb', line 6

def port
  @port
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
# File 'lib/hi/server.rb', line 12

def call(env)
  log Hi::Request.new(env).to_h

  [ 200, { 'Content-Type' => 'text/plain' }, ['hi'] ]
end