diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-08-10 21:16:44 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-08-10 21:16:44 -0400 |
commit | 055abed0e28681387377671bc16d40d075e3aaf7 (patch) | |
tree | fb038fde87156a164ba7ce64f80dffa0494286f7 /Zip.html | |
parent | 25199ab4c29057d7c0a73812fc8f2ac3605c1d86 (diff) | |
download | zip-crystal-055abed0e28681387377671bc16d40d075e3aaf7.tar.bz2 zip-crystal-055abed0e28681387377671bc16d40d075e3aaf7.zip |
update documentation
Diffstat (limited to 'Zip.html')
-rw-r--r-- | Zip.html | 86 |
1 files changed, 43 insertions, 43 deletions
@@ -118,22 +118,22 @@ <p>Reading from a zip file:</p> -<p># create output MemoryIO -mem_io = MemoryIO.new</p> +<pre><code><span class="c"># create output MemoryIO</span> +mem_io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> -<p># read from "foo.zip" -Zip.read("foo.zip") do |zip| -# read contents of "bar.txt" in "foo.zip" into mem_io -zip["bar.txt"].read(mem_io) -end</p> +<span class="c"># read from "foo.zip"</span> +<span class="t">Zip</span>.read(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + <span class="c"># read contents of "bar.txt" in "foo.zip" into mem_io</span> + zip[<span class="s">"bar.txt"</span>].read(mem_io) +<span class="k">end</span></code></pre> <p>Writing to a zip file:</p> -<p># write to "foo.zip" -Zip.write("foo.zip") do |zip| -# create "bar.txt" with contents "hello!" -zip.add("bar.txt", "hello!") -end</p> +<pre><code><span class="c"># write to "foo.zip"</span> +<span class="t">Zip</span>.write(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + <span class="c"># create "bar.txt" with contents "hello!"</span> + zip.add(<span class="s">"bar.txt"</span>, <span class="s">"hello!"</span>) +<span class="k">end</span></code></pre> @@ -254,14 +254,14 @@ end</p> <p>Example:</p> -<p># create memory io for contents of "bar.txt" -io = MemoryIO.new</p> +<pre><code><span class="c"># create memory io for contents of "bar.txt"</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> -<p># extract "bar.txt" from zip archive in Slice some_slice and -# save it to MemoryIO -Zip.read(some_slice) do |zip| -zip["bar.txt"].read(io) -end</p></div> +<span class="c"># extract "bar.txt" from zip archive in Slice some_slice and</span> +<span class="c"># save it to MemoryIO</span> +<span class="t">Zip</span>.read(some_slice) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + zip[<span class="s">"bar.txt"</span>].read(io) +<span class="k">end</span></code></pre></div> <br/> <div> @@ -281,13 +281,13 @@ end</p></div> <p>Example:</p> -<p># create memory io for contents of "bar.txt" -io = MemoryIO.new</p> +<pre><code><span class="c"># create memory io for contents of "bar.txt"</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> -<p># extract "bar.txt" from "./foo.zip" and save it to MemoryIO -Zip.read("./foo.zip") do |zip| -zip["bar.txt"].read(io) -end</p></div> +<span class="c"># extract "bar.txt" from "foo.zip" and save it to MemoryIO</span> +<span class="t">Zip</span>.read(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + zip[<span class="s">"bar.txt"</span>].read(io) +<span class="k">end</span></code></pre></div> <br/> <div> @@ -308,13 +308,13 @@ block.</p> <p>Example:</p> -<p># create memory io for contents of "bar.txt" -io = MemoryIO.new</p> +<pre><code><span class="c"># create memory io for contents of "bar.txt"</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> -<p># read "bar.txt" from "./foo.zip" -Zip.read(File.open("./foo.zip", "rb")) do |zip| -zip["bar.txt"].read(io) -end</p></div> +<span class="c"># read "bar.txt" from "foo.zip"</span> +<span class="t">Zip</span>.read(<span class="t">File</span>.open(<span class="s">"foo.zip"</span>, <span class="s">"rb"</span>)) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + zip[<span class="s">"bar.txt"</span>].read(io) +<span class="k">end</span></code></pre></div> <br/> <div> @@ -335,13 +335,13 @@ the given block. Returns number of bytes written.</p> <p>Example:</p> -<p># create output IO -File.open("foo.zip", "wb") do |io| -Zip.write(io) do |zip| -# add "bar.txt" with contents "hello!" -zip.add("bar.txt", "hello!") -end -end</p></div> +<pre><code><span class="c"># create output IO</span> +<span class="t">File</span>.open(<span class="s">"foo.zip"</span>, <span class="s">"wb"</span>) <span class="k">do</span> <span class="o">|</span>io<span class="o">|</span> + <span class="t">Zip</span>.write(io) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + <span class="c"># add "bar.txt" with contents "hello!"</span> + zip.add(<span class="s">"bar.txt"</span>, <span class="s">"hello!"</span>) + <span class="k">end</span> +<span class="k">end</span></code></pre></div> <br/> <div> @@ -362,11 +362,11 @@ the given block. Returns number of bytes written.</p> <p>Example:</p> -<p># create "foo.zip" -Zip.write("foo.zip") do |zip| -# add "bar.txt" with contents "hello!" -zip.add("bar.txt", "hello!") -end</p></div> +<pre><code><span class="c"># create "foo.zip"</span> +<span class="t">Zip</span>.write(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span> + <span class="c"># add "bar.txt" with contents "hello!"</span> + zip.add(<span class="s">"bar.txt"</span>, <span class="s">"hello!"</span>) +<span class="k">end</span></code></pre></div> <br/> <div> |