Class: Txgh::Handlers::ZipStreamResponse

Inherits:
StreamResponse show all
Defined in:
lib/txgh/handlers/zip_stream_response.rb

Instance Attribute Summary

Attributes inherited from StreamResponse

#attachment, #enum

Instance Method Summary collapse

Methods inherited from StreamResponse

#error, #headers, #initialize, #streaming?

Constructor Details

This class inherits a constructor from Txgh::Handlers::StreamResponse

Instance Method Details

#file_extensionObject



16
17
18
# File 'lib/txgh/handlers/zip_stream_response.rb', line 16

def file_extension
  '.zip'
end

#write_to(stream) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/txgh/handlers/zip_stream_response.rb', line 7

def write_to(stream)
  Zipline::OutputStream.open(stream) do |zipfile|
    enum.each do |file_name, contents|
      zipfile.put_next_entry(file_name, contents.bytesize)
      zipfile << contents
    end
  end
end