Class: Rabbit::ImageManipulable::Dia

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
SystemRunner
Defined in:
lib/rabbit/image/dia.rb

Constant Summary collapse

DIA_COMMANDS =
%w(dia)

Constants included from ModuleLoader

ModuleLoader::LOADERS

Instance Attribute Summary

Attributes inherited from Base

#animation, #filename, #original_height, #original_width, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SystemRunner

run

Methods inherited from Base

#[], #[]=, #draw, #height, #keep_ratio=, #keep_ratio?, #pixbuf, #relative_clip_height, #relative_clip_width, #relative_clip_x, #relative_clip_y, #resize, #width

Methods included from ModuleLoader

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

Constructor Details

#initialize(filename, props) ⇒ Dia

Returns a new instance of Dia.



58
59
60
61
# File 'lib/rabbit/image/dia.rb', line 58

def initialize(filename, props)
  init_svg_loader(filename, props)
  super
end

Class Method Details

.match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rabbit/image/dia.rb', line 33

def match?(filename)
  return true if File.extname(filename).downcase.end_with?(".dia")

  File.open(filename) do |f|
    begin
      first_line = f.gets
      second_line = f.gets
      return false unless second_line
      return false unless first_line.start_with?("<?xml")
      return false unless second_line.start_with?("<dia:diagram")
      true
    rescue EncodingError
      false
    end
  end
end