Class Prawn::Svg::Parser
In: lib/prawn/svg/parser.rb
Parent: Object

Prawn::Svg::Parser is responsible for parsing an SVG file and converting it into a tree of prawn-compatible method calls.

You probably do not want to use this class directly. Instead, use Prawn::Svg to draw SVG data to your Prawn::Document object.

This class is not passed the prawn object, so knows nothing about prawn specifically - this might be useful if you want to take this code and use it to convert SVG to another format.

Methods

new   parse  

Classes and Modules

Class Prawn::Svg::Parser::Path
Class Prawn::Svg::Parser::Text

Constants

CONTAINER_TAGS = %w(g svg symbol defs)
REQUIRED_ATTRIBUTES = { "line" => %w(x1 y1 x2 y2), "polyline" => %w(points), "polygon" => %w(points), "circle" => %w(r), "ellipse" => %w(rx ry), "rect" => %w(width height), "path" => %w(d)
USE_NEW_CIRCLE_CALL = Prawn::Document.new.respond_to?(:circle)
USE_NEW_ELLIPSE_CALL = Prawn::Document.new.respond_to?(:ellipse)

Public Class methods

Construct a Parser object.

The data argument is SVG data.

bounds is a tuple [width, height] that specifies the bounds of the drawing space in points.

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

Public Instance methods

Parse the SVG data and return a call tree. The returned Array is in the format:

  [
    ['prawn_method_name', ['argument1', 'argument2'], []],
    ['method_that_takes_a_block', ['argument1', 'argument2'], [
      ['method_called_inside_block', ['argument'], []]
    ]
  ]

[Validate]