Class: ImageOptim::ImagePath
- Inherits:
-
FSPath
- Object
- FSPath
- ImageOptim::ImagePath
- Defined in:
- lib/image_optim/image_path.rb
Instance Method Summary collapse
-
#copy(dst) ⇒ Object
Copy file to dest preserving attributes.
-
#format ⇒ Object
Get format using ImageSize.
-
#replace(src) ⇒ Object
Atomic replace src with self.
-
#temp_path(*args, &block) ⇒ Object
Get temp path for this file with same extension.
Instance Method Details
#copy(dst) ⇒ Object
Copy file to dest preserving attributes
15 16 17 |
# File 'lib/image_optim/image_path.rb', line 15 def copy(dst) FileUtils.copy_file(self, dst, true) end |
#format ⇒ Object
Get format using ImageSize
30 31 32 |
# File 'lib/image_optim/image_path.rb', line 30 def format open{ |f| ImageSize.new(f) }.format end |
#replace(src) ⇒ Object
Atomic replace src with self
20 21 22 23 24 25 26 27 |
# File 'lib/image_optim/image_path.rb', line 20 def replace(src) src = self.class.new(src) src.temp_path(src.dirname) do |temp| src.copy(temp) temp.write(read) temp.rename(src) end end |
#temp_path(*args, &block) ⇒ Object
Get temp path for this file with same extension
9 10 11 12 |
# File 'lib/image_optim/image_path.rb', line 9 def temp_path(*args, &block) ext = extname self.class.temp_file_path([basename(ext), ext], *args, &block) end |