Class: Rabbit::ImageManipulable::SVG

Inherits:
Base
  • Object
show all
Defined in:
lib/rabbit/image/svg.rb

Constant Summary

Constants included from ModuleLoader

ModuleLoader::LOADERS

Instance Attribute Summary

Attributes inherited from Base

#height, #original_height, #original_width, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #initialize, #keep_ratio, #keep_ratio=, #resize

Methods included from ModuleLoader

extend_object, #find_loader, #loaders, #push_loader, #unshift_loader

Constructor Details

This class inherits a constructor from Rabbit::ImageManipulable::Base

Class Method Details

.match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/rabbit/image/svg.rb', line 13

def match?(filename)
  File.open(filename) do |f|
    /<svg|<!DOCTYPE\s+svg/ =~ f.read(200)
  end
end

Instance Method Details

#draw(canvas, x, y, params = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rabbit/image/svg.rb', line 20

def draw(canvas, x, y, params={})
  if @handle
    default_params = {
      :width => width,
      :height => height,
    }
    canvas.draw_rsvg_handle(@handle, x, y, default_params.merge(params))
  else
    super
  end
end

#pixbufObject



32
33
34
# File 'lib/rabbit/image/svg.rb', line 32

def pixbuf
  @pixbuf ||= to_pixbuf(width, height)
end