Chapter 9. Output Functions

Web << output
Write output to the browser.
Web::clear
Reset output buffer. Fails if headers have been sent.
Web::close
Flushes the output and, if applicable, saves the session.
Web::flush
Send header to the client, and flush any buffered output
Web::puts(output)
Write output to the browser with line breaks.
Web::write(output)
Write output to the browser.
Web::send_file( filename )
This method will replace the contents of the output buffer with the content read from the given filename. If the Content-Type header has not already been set, it will guess an appropriate mime-type from the extension of the file.
Web::send_lib_file( relative_filename )
Using Web::send_file(filename), sends the contents of a file from the ruby lib to the client. Filename is relative to the file of Kernel::caller. This method is intended to help the distribution of web applications as normal ruby libraries.
# sends ".../ruby/site_lib/1.8/web/resources/logo.gif" to the client
Web::send_lib_file( 'resources/logo.gif' )
Web::unbuffered?
Returns whether output buffering is being used. By default, output is buffered.
Web::filter
Start an output buffer. aka Web::ob_start. Yields content for filtering before being written out:
Web::filter do |content|
  # ... filter  content   
end
Web::ob_flush
Flush (send) the output buffer
Web::ob_clean
Erase and discard contents of the output buffer
Web::ob_end_clean
Erase contents of output buffer, and discard the buffer itself
Web::ob_end_flush
Flush (send) the output buffer and discard the buffer itself
Web::ob_get_clean
Get current buffer contents and delete current output buffer
Web::ob_get_contents
Return the contents of the output buffer
Web::ob_get_flush
Flush the output buffer, return it as a string and turn off output buffering
Web::ob_get_length
Return the length of the output buffer
Web::ob_get_level
Return the nesting level of the output buffering mechanism
Web::ob_list_handlers
List all output handlers in use