Parent

Methods

Prawn::Svg::Parser

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.

Public Class Methods

new(document) click to toggle source

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.

# File lib/prawn/svg/parser.rb, line 27
def initialize(document)
  @document = document
end

Public Instance Methods

parse() click to toggle source

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'], []]
  ]
]
# File lib/prawn/svg/parser.rb, line 41
def parse
  @document.warnings.clear

  calls = [['fill_color', '000000', []]]
  root_element = Prawn::Svg::Element.new(@document, @document.root, calls, :ids => {}, :fill => true)

  parse_element(root_element)
  calls
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.