From 055abed0e28681387377671bc16d40d075e3aaf7 Mon Sep 17 00:00:00 2001
From: Paul Duncan
Example:
-# create IO from "/path/to/bar.txt" -File.open("/path/to/bar.txt, "rb") do |io| -# write to "foo.zip" -Zip.write("foo.zip") do |zip| -# add "bar.txt" with contents of given IO -zip.add("bar.txt", io) -end -end
+# create IO from "/path/to/bar.txt"
+File.open("/path/to/bar.txt, "rb") do |io|
+ # write to "foo.zip"
+ Zip.write("foo.zip") do |zip|
+ # add "bar.txt" with contents of given IO
+ zip.add("bar.txt", io)
+ end
+end
Example:
-# write to "foo.zip" -Zip.write("foo.zip") do |zip| -# add "bar.txt" with contents "hello!" -zip.add("bar.txt", "hello!") -end
# write to "foo.zip"
+Zip.write("foo.zip") do |zip|
+ # add "bar.txt" with contents "hello!"
+ zip.add("bar.txt", "hello!")
+end
Example:
-# write to "foo.zip" -Zip.write("foo.zip") do |zip| -# add local file "/path/to/bar.txt" as "bar.txt" -zip.add_file("bar.txt", "/path/to/bar.txt") -end
# write to "foo.zip"
+Zip.write("foo.zip") do |zip|
+ # add local file "/path/to/bar.txt" as "bar.txt"
+ zip.add_file("bar.txt", "/path/to/bar.txt")
+end
Example:
-Zip.write("foo.zip") do |zip| -# add "bar.txt" -zip.add_file("bar.txt", "/path/to/bar.txt")
+Zip.write("foo.zip") do |zip|
+ # add "bar.txt"
+ zip.add_file("bar.txt", "/path/to/bar.txt")
-# print number of bytes written so far
-puts "bytes written so far: #{zip.bytes_written}"
-
-end
+ # print number of bytes written so far
+ puts "bytes written so far: #{zip.bytes_written}"
+end