Class: Docwatch::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/docwatch/connection.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(renderer, watcher, session) ⇒ Connection

Returns a new instance of Connection.



3
4
5
6
7
# File 'lib/docwatch/connection.rb', line 3

def initialize(renderer, watcher, session)
    @renderer = renderer
    @watcher = watcher
    @session = session
end

Class Method Details

.handle(*opts) ⇒ Object



9
10
11
# File 'lib/docwatch/connection.rb', line 9

def self.handle(*opts)
    new(*opts).handle
end

Instance Method Details

#handleObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/docwatch/connection.rb', line 13

def handle
    case @session.path
    when '/'
        @session.respond_with_html(@renderer.to_html)
    when '/wait'
        @watcher.wait
        @session.respond_with_text('OK')
    else
        @session.respond_with_404
    end
end