Sha256: 6a7232032b0eb079a33766724bc3d40ca3463bea75e585667e9eba7898418708
Contents?: true
Size: 596 Bytes
Versions: 8
Compression:
Stored size: 596 Bytes
Contents
require 'rubygems' require 'zip' module UsefulRenderers module ZipRenderable # You need to call this on collection of File objects # or objects which provides :read & :path method def to_zip(*) return '' if empty? return '' unless first.respond_to?(:path) && first.respond_to?(:read) stringio = Zip::OutputStream.write_buffer do |zio| self.each do |obj| filename = File.basename(obj.path) zio.put_next_entry(filename) zio.write obj.read end end stringio.rewind stringio.sysread end end end
Version data entries
8 entries across 8 versions & 1 rubygems