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)


32
33
34
35
36
37
38
39
40
# 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

Instance Method Details

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



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rabbit/image/svg.rb', line 43

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



55
56
57
# File 'lib/rabbit/image/svg.rb', line 55

def pixbuf
  @handle.pixbuf
end