Class: ImageOptim::OptimizedPath

Inherits:
Path
  • Object
show all
Defined in:
lib/image_optim/optimized_path.rb

Overview

Holds optimized image with reference to original and its size

Constant Summary

Constants inherited from Path

Path::NULL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Path

convert, #copy, #copy_metadata, #image_format, #move, #replace, #temp_path

Constructor Details

#initialize(path, original_or_size = nil) ⇒ OptimizedPath

Returns a new instance of OptimizedPath.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/image_optim/optimized_path.rb', line 10

def initialize(path, original_or_size = nil)
  path = Path.convert(path)
  super(path)
  if original_or_size.is_a?(Integer)
    @original = path
    @original_size = original_or_size
  elsif original_or_size
    @original = Path.convert(original_or_size)
    @original_size = @original.size
  end
end

Instance Attribute Details

#originalObject (readonly)

Original path, use original_size to get its size as original can be overwritten



24
25
26
# File 'lib/image_optim/optimized_path.rb', line 24

def original
  @original
end

#original_sizeObject (readonly)

Stored size of original



27
28
29
# File 'lib/image_optim/optimized_path.rb', line 27

def original_size
  @original_size
end