class OddJob::Info

Webrick servlet for creating the information page.

Public Class Methods

new(server, cmd_usage, *options) click to toggle source

Standard servlet initialization function with an additional cmd_usage argument for specifying the command line usage of the OddJob module’s calling entity.

Calls superclass method
# File lib/oddjob.rb, line 133
def initialize(server, cmd_usage, *options)
  @usage = cmd_usage
  super(server, options)
end

Public Instance Methods

do_GET(request, response) click to toggle source

Respond to get request, returns informational page.

# File lib/oddjob.rb, line 140
def do_GET(request, response)
  response.status = 200
  response['Content-Type'] = "text/html"
  response.body = info_page
end

Protected Instance Methods

info_page() click to toggle source

Render the HTML for the informational page.

# File lib/oddjob.rb, line 150
def info_page
  html = [
    "  <h2>#{File.basename($0)}</h2>",
    "  <p>Version: <strong>#{VERSION}</strong></p>"
  ]
  html << "  <pre>#{@usage}</pre>" unless @usage.nil?
  page(html, "Info")
end