Sha256: a66c7903aff46f3de910d7239003ccc20d87aa2f1feec1bf39d9aa53fd7a5769

Contents?: true

Size: 444 Bytes

Versions: 3

Compression:

Stored size: 444 Bytes

Contents

module ImageOptimRake
  class Image < Struct.new(:path, :original_size, :compressed_size)
    def initialize(path)
      self.path          = path
      self.original_size = open(path, "rb").size
    end

    def reload_size!
      self.compressed_size = open(path, "rb").size
    end

    def percentage
      (original_size - compressed_size) == 0 ? 0.0 : (original_size - compressed_size).to_f / original_size.to_f * 100.0
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
image_optim_rake-0.0.4 lib/image_optim_rake/image.rb
image_optim_rake-0.0.3 lib/image_optim_rake/image.rb
image_optim_rake-0.0.2 lib/image_optim_rake/image.rb