Class: ImageRuby::DevilPersistor

Inherits:
FilePersistor
  • Object
show all
Includes:
TempFileMethods
Defined in:
lib/devil_persistor/devil_persistor.rb

Instance Method Summary collapse

Methods included from TempFileMethods

#create_temp_file, #create_temp_path, #use_temp_file

Instance Method Details

#persist(image, path, format) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/devil_persistor/devil_persistor.rb', line 30

def persist(image,path,format)

  if path.respond_to? :devil_path
    raise UnableToPersistException
  end

  tmppath = create_temp_path("img") + ".bmp"

  def tmppath.devil_path
  end

  FilePersistor.persist(image,tmppath,:bmp)

  use_temp_file(tmppath) do
    begin
      Devil.with_image(tmppath) do |img|
        img.save(path)
      end
    rescue RuntimeError
      raise UnableToEncodeException
    end
  end

  nil
end