Class: ImageRuby::EncoderPersistor

Inherits:
FilePersistor show all
Defined in:
lib/imageruby/persistor/encoder_persistor.rb

Instance Method Summary collapse

Methods inherited from FilePersistor

persist

Instance Method Details

#persist(image, path, format) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/imageruby/persistor/encoder_persistor.rb', line 25

def persist(image,path,format)

  encoded_string = String.new

  begin
    ImageRuby::Encoder.encode(image,format,encoded_string)

    File.open(path,"wb") do |file|
      file.write encoded_string
    end

  rescue ImageRuby::Encoder::UnableToEncodeException
    raise UnableToPersistException
  end
  nil
end