diff options
-rw-r--r-- | Zip.html | 86 | ||||
-rw-r--r-- | Zip/Archive.html | 32 | ||||
-rw-r--r-- | Zip/Entry.html | 53 | ||||
-rw-r--r-- | Zip/Error.html | 3 | ||||
-rw-r--r-- | Zip/Extra.html | 10 | ||||
-rw-r--r-- | Zip/Writer.html | 49 |
6 files changed, 117 insertions, 116 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> diff --git a/Zip/Archive.html b/Zip/Archive.html index ea6e914..332b0f1 100644 --- a/Zip/Archive.html +++ b/Zip/Archive.html @@ -298,9 +298,9 @@ <p>Example:</p> -<p># get bar.txt and read it into memory io -io = MemoryIO.new -zip["bar.txt"].read(io)</p></div> +<pre><code><span class="c"># get bar.txt and read it into memory io</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> +zip[<span class="s">"bar.txt"</span>].read(io)</code></pre></div> <br/> <div> @@ -320,9 +320,9 @@ zip["bar.txt"].read(io)</p></div> <p>Example:</p> -<p># read third entry from archive into memory io -io = MemoryIO.new -zip[2].read(io)</p></div> +<pre><code><span class="c"># read third entry from archive into memory io</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> +zip[<span class="n">2</span>].read(io)</code></pre></div> <br/> <div> @@ -342,11 +342,11 @@ zip[2].read(io)</p></div> <p>Example:</p> -<p># read third entry from archive into memory io -if e = zip[2] -io = MemoryIO.new -e.read(io) -end</p></div> +<pre><code><span class="c"># read third entry from archive into memory io</span> +<span class="k">if</span> e <span class="o">=</span> zip[<span class="n">2</span>]? + io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> + e.read(io) +<span class="k">end</span></code></pre></div> <br/> <div> @@ -366,11 +366,11 @@ end</p></div> <p>Example:</p> -<p># read bar.txt into memory io if it exists -if e = zip["bar.txt"]? -io = MemoryIO.new -e.read(io) -end</p></div> +<pre><code><span class="c"># read bar.txt into memory io if it exists</span> +<span class="k">if</span> e <span class="o">=</span> zip[<span class="s">"bar.txt"</span>]? + io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> + e.read(io) +<span class="k">end</span></code></pre></div> <br/> <div> diff --git a/Zip/Entry.html b/Zip/Entry.html index 6626777..9e31614 100644 --- a/Zip/Entry.html +++ b/Zip/Entry.html @@ -121,18 +121,17 @@ specific archive entry.</p> <p>Example:</p> -<p># create MemoryIO -io = MemoryIO.new</p> +<pre><code><span class="c"># create MemoryIO</span> +io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span> -<p># open "foo.zip" -Zip.read("foo.zip") do |zip| -# get "bar.txt" entry from "foo.zip" -e = zip["bar.txt"]</p> +<span class="c"># open "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"># get "bar.txt" entry from "foo.zip"</span> + e <span class="o">=</span> zip[<span class="s">"bar.txt"</span>] -<pre><code><span class="c"># read contents of "bar.txt" into io</span> -e.read(io)</code></pre> - -<p>end</p> + <span class="c"># read contents of "bar.txt" into io</span> + e.read(io) +<span class="k">end</span></code></pre> @@ -463,11 +462,11 @@ file's entry in the Central Directory, and this method returns the <p>Example:</p> -<p># open "./foo.zip" -Zip.read("./foo.zip") do |zip| -# get array of local extra attributes from "bar.txt" -extras = zip["bar.txt"].local_extras -end</p></div> +<pre><code><span class="c"># open "./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"># get array of local extra attributes from "bar.txt"</span> + extras <span class="o">=</span> zip[<span class="s">"bar.txt"</span>].local_extras +<span class="k">end</span></code></pre></div> <br/> <div> @@ -532,14 +531,14 @@ compression method is unsupported.</p> <p>Example:</p> -<p># open "output-bar.txt" for writing -File.open("output-bar.txt", "wb") do |io| -# open archive "./foo.zip" -Zip.read("foo.zip") do |zip| -# write contents of "bar.txt" to "output-bar.txt" -zip["foo.txt"].read(io) -end -end</p></div> +<pre><code><span class="c"># open "output-bar.txt" for writing</span> +<span class="t">File</span>.open(<span class="s">"output-bar.txt"</span>, <span class="s">"wb"</span>) <span class="k">do</span> <span class="o">|</span>io<span class="o">|</span> + <span class="c"># open archive "./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"># write contents of "bar.txt" to "output-bar.txt"</span> + zip[<span class="s">"foo.txt"</span>].read(io) + <span class="k">end</span> +<span class="k">end</span></code></pre></div> <br/> <div> @@ -559,10 +558,10 @@ end</p></div> <p>Example:</p> -<p>Zip.read("foo.zip") do |zip| -size = zip["bar.txt"].size -puts "bar.txt is #{size} bytes." -end</p></div> +<pre><code><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> + size <span class="o">=</span> zip[<span class="s">"bar.txt"</span>].size + puts <span class="s">"bar.txt is </span><span class="i">#{</span></span>size<span class="s"><span class="i">}</span> bytes."</span> +<span class="k">end</span></code></pre></div> <br/> <div> diff --git a/Zip/Error.html b/Zip/Error.html index fc71ef7..d2a611e 100644 --- a/Zip/Error.html +++ b/Zip/Error.html @@ -116,6 +116,9 @@ <p>Wrapper class for exceptions.</p> +<p>You shouldn't need to instantiate this class directly; it is raised +by other classes on error.</p> + diff --git a/Zip/Extra.html b/Zip/Extra.html index cb489df..3ea15f3 100644 --- a/Zip/Extra.html +++ b/Zip/Extra.html @@ -121,11 +121,11 @@ <p>Example:</p> -<p># open "foo.zip" -Zip.read("foo.zip") do |zip| -# get extra data associated with "bar.txt" -extras = zip["bar.txt"].extras -end</p> +<pre><code><span class="c"># open "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"># get extra data associated with "bar.txt"</span> + extras <span class="o">=</span> zip[<span class="s">"bar.txt"</span>].extras +<span class="k">end</span></code></pre> diff --git a/Zip/Writer.html b/Zip/Writer.html index c28c13e..894055d 100644 --- a/Zip/Writer.html +++ b/Zip/Writer.html @@ -255,14 +255,14 @@ return the number of bytes written.</p> <p>Example:</p> -<p># 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</p></div> +<pre><code><span class="c"># create IO from "/path/to/bar.txt"</span> +<span class="t">File</span>.open(<span class="s">"/path/to/bar.txt, "</span>rb<span class="s">") do |io| + # write to "</span>foo.zip<span class="s">" + Zip.write("</span>foo.zip<span class="s">") do |zip| + # add "</span>bar.txt<span class="s">" with contents of given IO + zip.add("</span>bar.txt<span class="s">", io) + end +end</code></pre></div> <br/> <div> @@ -283,11 +283,11 @@ written.</p> <p>Example:</p> -<p># write to "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"># 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"># 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> @@ -308,11 +308,11 @@ of bytes written.</p> <p>Example:</p> -<p># 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</p></div> +<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"># add local file "/path/to/bar.txt" as "bar.txt"</span> + zip.add_file(<span class="s">"bar.txt"</span>, <span class="s">"/path/to/bar.txt"</span>) +<span class="k">end</span></code></pre></div> <br/> <div> @@ -332,14 +332,13 @@ end</p></div> <p>Example:</p> -<p>Zip.write("foo.zip") do |zip| -# add "bar.txt" -zip.add_file("bar.txt", "/path/to/bar.txt")</p> +<pre><code><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"</span> + zip.add_file(<span class="s">"bar.txt"</span>, <span class="s">"/path/to/bar.txt"</span>) -<pre><code><span class="c"># print number of bytes written so far</span> -puts <span class="s">"bytes written so far: </span><span class="i">#{</span></span>zip.bytes_written<span class="s"><span class="i">}</span>"</span></code></pre> - -<p>end</p></div> + <span class="c"># print number of bytes written so far</span> + puts <span class="s">"bytes written so far: </span><span class="i">#{</span></span>zip.bytes_written<span class="s"><span class="i">}</span>"</span> +<span class="k">end</span></code></pre></div> <br/> <div> |