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


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/image_optim/optimized_path.rb', line 6

def initialize(path, original_or_size = nil)
  path = Path.convert(path)
  __setobj__(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


20
21
22
# File 'lib/image_optim/optimized_path.rb', line 20

def original
  @original
end

#original_sizeObject (readonly)

Stored size of original


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

def original_size
  @original_size
end