Class: Rabbit::ImageManipulable::Dia

Inherits:
Base
  • Object
show all
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

#[], #[]=, delegate, #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, canvas: nil) ⇒ Dia

Returns a new instance of Dia.



50
51
52
53
# File 'lib/rabbit/image/dia.rb', line 50

def initialize(filename, props, canvas: nil)
  init_delegated_loader(filename, props, canvas)
  super
end

Class Method Details

.match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


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

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