Class: Hi::Server
- Inherits:
-
Object
- Object
- Hi::Server
- Defined in:
- lib/hi/server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(port = nil) ⇒ Server
constructor
A new instance of Server.
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
#port ⇒ Object (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 |