diff options
Diffstat (limited to 'Zip/Entry.html')
-rw-r--r-- | Zip/Entry.html | 53 |
1 files changed, 26 insertions, 27 deletions
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> |