Class: ImageOptim::Handler
- Inherits:
-
Object
- Object
- ImageOptim::Handler
- Defined in:
- lib/image_optim/handler.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#cleanup ⇒ Object
Remove extra temp files.
-
#initialize(original) ⇒ Handler
constructor
A new instance of Handler.
- #process ⇒ Object
Constructor Details
#initialize(original) ⇒ Handler
Returns a new instance of Handler.
6 7 8 9 10 11 |
# File 'lib/image_optim/handler.rb', line 6 def initialize(original) raise ArgumentError, 'original should respond to temp_path' unless original.respond_to?(:temp_path) @original = original @result = nil end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/image_optim/handler.rb', line 5 def result @result end |
Instance Method Details
#cleanup ⇒ Object
Remove extra temp files
28 29 30 31 32 33 |
# File 'lib/image_optim/handler.rb', line 28 def cleanup if @dst @dst.unlink @dst = nil end end |
#process ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/image_optim/handler.rb', line 13 def process @src ||= @original @dst ||= @original.temp_path if yield @src, @dst @result = @dst if @src == @original @src, @dst = @dst, nil else @src, @dst = @dst, @src end end end |