Sha256: fece2fcbaa283968d076f92a8a97b31ec1bc7380369845169c4c1ad28231990c

Contents?: true

Size: 525 Bytes

Versions: 1

Compression:

Stored size: 525 Bytes

Contents

class RailsImager::CacheHandler
  def initialize(args = {})
    @args = args
  end

  def path
    unless @path
      require "tmpdir"
      @path = "#{Dir.tmpdir}/rails-imager-cache"
      Dir.mkdir(@path) unless Dir.exist?(@path)
    end

    return @path
  end

  def clear(args = {})
    Dir.foreach(path) do |file|
      next if file == "." || file == ".."
      next unless file.end_with?(".png")

      full_path = "#{path}/#{file}"
      File.unlink(full_path)
      yield full_path if block_given?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_imager-0.0.30 lib/rails_imager/cache_handler.rb