module DyiRails::Streaming
Provides a set of methods for sending the image using DYI on the Rails' controller.
Public Instance Methods
send_dyi_image(canvas, options={})
click to toggle source
Sends image the image using DYI on the Rails' controller. @param [DYI::Canvas, DYI::Chart::Base] canvas a canvas that hold the image @option options [Symbol, String] :format format of the image. Default to
+:svg+
@option options [String] :namespace XML namespace when XML format (e.g.
SVG) is specified at +:format+ option. If nothing is specified, XML namespace is not used
@option options [String] :file_name suggests a filename for the browser to
use
@option options [String] :disposition specifies whether the file will be
shown inline or downloaded. Valid values are <tt>'inline'</tt> and <tt>'attachment'</tt> (default)
@option options [String] :status specifies the status code to send with
the response. Defaults to <tt>'200 OK'</tt>
@example
class TeamsController < ApplicationController include DyiRails::Streaming # responses /teams/emblem/any_id.svg def emblem # creates image using DYI canvas = DYI::Canvas.new(200, 150) # codes to draw an image # sends image data send_dyi_image(canvas, :format => params['format']) end end
# File lib/dyi_rails/streaming.rb, line 56 def send_dyi_image(canvas, options={}) opt = options.clone format = opt.delete(:format) || :svg namespace = opt.delete(:namespace) opt[:type] = DyiRails.mime_type(format) send_data(canvas.string(format, :namespace => namespace), opt) end