class Zip::SliceSource

Overview

Use slice as a source for Archive#add or Archive#replace.

Example

# create slice
slice = Slice.new(10) { |i| i + 10 }

# create source
source = SliceSource.new(zip, slice)

# add slice to archive as "foo.txt"
zip.add("foo.txt", source)

Defined in:

zip/sources.cr

Constructors

Instance methods inherited from class Zip::Source

to_unsafe : LibZip::ZipSourceT to_unsafe

Constructor Detail

def self.new(zip : Archive, s : Slice) #

Create a new SliceSource from the given slice.

Raises an exception if this SliceSource could not be created.

Example

# create slice
slice = Slice.new(10) { |i| i + 10 }

# create source
source = SliceSource.new(zip, slice)

# add slice to archive as "foo.txt"
zip.add("foo.txt", source)

[View source]