class Rabbit::ImageManipulable::SVG

Public Class Methods

match?(filename) click to toggle source
# File lib/rabbit/image/svg.rb, line 32
def match?(filename)
  File.open(filename) do |f|
    begin
      /<svg|<!DOCTYPE\s+svg/ =~ f.read(200)
    rescue EncodingError
      false
    end
  end
end

Public Instance Methods

draw(canvas, x, y, params={}) click to toggle source
Calls superclass method Rabbit::ImageManipulable::Base#draw
# File lib/rabbit/image/svg.rb, line 43
def draw(canvas, x, y, params={})
  if @handle
    default_params = default_draw_params(x, y)
    canvas.draw_rsvg_handle(@handle, x, y, default_params.merge(params))
  else
    super
  end
end
pixbuf() click to toggle source
# File lib/rabbit/image/svg.rb, line 52
def pixbuf
  @handle.pixbuf
end

Private Instance Methods

filename() click to toggle source
# File lib/rabbit/image/svg.rb, line 66
def filename
  File.expand_path(@filename)
end
rsvg_environment() { |name| ... } click to toggle source
# File lib/rabbit/image/svg.rb, line 70
def rsvg_environment
  dir = File.dirname(filename)
  name = File.basename(filename)
  Dir.chdir(dir) do
    yield(name)
  end
end
update_size() click to toggle source
# File lib/rabbit/image/svg.rb, line 57
def update_size
  rsvg_environment do |name|
    @handle = Rsvg::Handle.new(:path => name)
    dim = @handle.dimensions
    @width = dim.width
    @height = dim.height
  end
end