Parent

Methods

Prawn::Svg::Interface

Constants

DEFAULT_FONT_PATHS

Attributes

font_path[RW]
data[R]
document[R]
options[R]
prawn[R]

Public Class Methods

new(data, prawn, options) click to toggle source

Creates a Prawn::Svg object.

data is the SVG data to convert. prawn is your Prawn::Document object.

options must contain the key :at, which takes a tuple of x and y co-ordinates.

options can optionally contain the key :width or :height. If both are specified, only :width will be used.

# File lib/prawn/svg/interface.rb, line 27
def initialize(data, prawn, options)
  @data = data
  @prawn = prawn
  @options = options
    
  @options[:at] or raise "options[:at] must be specified"

  prawn.font_families.update(Prawn::Svg::Font.installed_fonts)

  @document = Document.new(data, [prawn.bounds.width, prawn.bounds.height], options)        
end

Public Instance Methods

draw() click to toggle source

Draws the SVG to the Prawn::Document object.

# File lib/prawn/svg/interface.rb, line 42
def draw
  prawn.bounding_box(@options[:at], :width => @document.width, :height => @document.height) do
    prawn.save_graphics_state do
      proc_creator(prawn, Parser.new(@document).parse).call
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.