class ImageVise::FileResponse

Wrappers a given Tempfile for a Rack response. Will close and unlink the Tempfile it contains.

Constants

ONE_CHUNK_BYTES

Public Class Methods

new(file) click to toggle source
# File lib/image_vise/file_response.rb, line 5
def initialize(file)
  @file = file
end

Public Instance Methods

close() click to toggle source
# File lib/image_vise/file_response.rb, line 19
def close
  ImageVise.close_and_unlink(@file)
end
each() { |data| ... } click to toggle source
# File lib/image_vise/file_response.rb, line 9
def each
  @file.flush # Make sure all the writes have been synchronized
  # We can easily open another file descriptor
  File.open(@file.path, 'rb') do |my_file_descriptor|
    while data = my_file_descriptor.read(ONE_CHUNK_BYTES)
      yield(data)
    end
  end
end