File: C:/Ruby27-x64/share/doc/ruby/html/Zlib/GzipFile.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class Zlib::GzipFile - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "../";
var index_rel_prefix = "../";
</script>
<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="../index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="../table_of_contents.html#pages">Pages</a>
<a href="../table_of_contents.html#classes">Classes</a>
<a href="../table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="../Object.html">Object</a>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-wrap">::wrap</a>
<li ><a href="#method-i-close">#close</a>
<li ><a href="#method-i-closed-3F">#closed?</a>
<li ><a href="#method-i-comment">#comment</a>
<li ><a href="#method-i-crc">#crc</a>
<li ><a href="#method-i-finish">#finish</a>
<li ><a href="#method-i-level">#level</a>
<li ><a href="#method-i-mtime">#mtime</a>
<li ><a href="#method-i-orig_name">#orig_name</a>
<li ><a href="#method-i-os_code">#os_code</a>
<li ><a href="#method-i-sync">#sync</a>
<li ><a href="#method-i-sync-3D">#sync=</a>
<li ><a href="#method-i-to_io">#to_io</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-Zlib::GzipFile">
<h1 id="class-Zlib::GzipFile" class="class">
class Zlib::GzipFile
</h1>
<section class="description">
<p><a href="GzipFile.html"><code>Zlib::GzipFile</code></a> is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, <a href="GzipReader.html"><code>Zlib::GzipReader</code></a> for reading, and <a href="GzipWriter.html"><code>Zlib::GzipWriter</code></a> for writing.</p>
<p><a href="GzipReader.html"><code>GzipReader</code></a> should be used by associating an <a href="../IO.html"><code>IO</code></a>, or IO-like, object.</p>
<h2 id="class-Zlib::GzipFile-label-Method+Catalogue"><a href="../Method.html"><code>Method</code></a> Catalogue<span><a href="#class-Zlib::GzipFile-label-Method+Catalogue">¶</a> <a href="#top">↑</a></span></h2>
<ul><li>
<p><a href="GzipFile.html#method-c-wrap"><code>::wrap</code></a></p>
</li><li>
<p><a href="../Kernel.html#method-c-open"><code>::open</code></a> (<a href="GzipReader.html#method-c-open"><code>Zlib::GzipReader::open</code></a> and <a href="GzipWriter.html#method-c-open"><code>Zlib::GzipWriter::open</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-close"><code>close</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-closed-3F"><code>closed?</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-comment"><code>comment</code></a></p>
</li><li>
<p>comment= (<a href="GzipWriter.html#method-i-comment-3D"><code>Zlib::GzipWriter#comment=</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-crc"><code>crc</code></a></p>
</li><li>
<p>eof? (<a href="GzipReader.html#method-i-eof-3F"><code>Zlib::GzipReader#eof?</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-finish"><code>finish</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-level"><code>level</code></a></p>
</li><li>
<p>lineno (<a href="GzipReader.html#method-i-lineno"><code>Zlib::GzipReader#lineno</code></a>)</p>
</li><li>
<p>lineno= (<a href="GzipReader.html#method-i-lineno-3D"><code>Zlib::GzipReader#lineno=</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-mtime"><code>mtime</code></a></p>
</li><li>
<p>mtime= (<a href="GzipWriter.html#method-i-mtime-3D"><code>Zlib::GzipWriter#mtime=</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-orig_name"><code>orig_name</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-orig_name"><code>orig_name</code></a> (<a href="GzipWriter.html#method-i-orig_name-3D"><code>Zlib::GzipWriter#orig_name=</code></a>)</p>
</li><li>
<p><a href="GzipFile.html#method-i-os_code"><code>os_code</code></a></p>
</li><li>
<p>path (when the underlying <a href="../IO.html"><code>IO</code></a> supports path)</p>
</li><li>
<p><a href="GzipFile.html#method-i-sync"><code>sync</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-sync-3D"><code>sync=</code></a></p>
</li><li>
<p><a href="GzipFile.html#method-i-to_io"><code>to_io</code></a></p>
</li></ul>
<p>(due to internal structure, documentation may appear under <a href="GzipReader.html"><code>Zlib::GzipReader</code></a> or <a href="GzipWriter.html"><code>Zlib::GzipWriter</code></a>)</p>
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-wrap" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
Zlib::GzipReader.wrap(io, ...) { |gz| ... }
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-heading">
<span class="method-callseq">
Zlib::GzipWriter.wrap(io, ...) { |gz| ... }
</span>
</div>
<div class="method-description">
<p>Creates a <a href="GzipReader.html"><code>GzipReader</code></a> or <a href="GzipWriter.html"><code>GzipWriter</code></a> associated with <code>io</code>, passing in any necessary extra options, and executes the block with the newly created object just like <a href="../File.html#method-c-open"><code>File.open</code></a>.</p>
<p>The <a href="GzipFile.html"><code>GzipFile</code></a> object will be closed automatically after executing the block. If you want to keep the associated <a href="../IO.html"><code>IO</code></a> object open, you may call <a href="GzipFile.html#method-i-finish"><code>Zlib::GzipFile#finish</code></a> method in the block.</p>
<div class="method-source-code" id="wrap-source">
<pre>static VALUE
rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
{
return gzfile_wrap(argc, argv, klass, 0);
}</pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-close" class="method-detail ">
<div class="method-heading">
<span class="method-name">close</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Closes the <a href="GzipFile.html"><code>GzipFile</code></a> object. This method calls close method of the associated <a href="../IO.html"><code>IO</code></a> object. Returns the associated <a href="../IO.html"><code>IO</code></a> object.</p>
<div class="method-source-code" id="close-source">
<pre>static VALUE
rb_gzfile_close(VALUE obj)
{
struct gzfile *gz;
VALUE io;
TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
if (!ZSTREAM_IS_READY(&gz->z)) {
return Qnil;
}
io = gz->io;
gzfile_close(gz, 1);
return io;
}</pre>
</div>
</div>
</div>
<div id="method-i-closed-3F" class="method-detail ">
<div class="method-heading">
<span class="method-name">closed?</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Same as <a href="../IO.html#method-i-closed-3F"><code>IO#closed?</code></a></p>
<div class="method-source-code" id="closed-3F-source">
<pre>static VALUE
rb_gzfile_closed_p(VALUE obj)
{
struct gzfile *gz;
TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
return NIL_P(gz->io) ? Qtrue : Qfalse;
}</pre>
</div>
</div>
</div>
<div id="method-i-comment" class="method-detail ">
<div class="method-heading">
<span class="method-name">comment</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns comments recorded in the gzip file header, or nil if the comments is not present.</p>
<div class="method-source-code" id="comment-source">
<pre>static VALUE
rb_gzfile_comment(VALUE obj)
{
VALUE str = get_gzfile(obj)->comment;
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
return str;
}</pre>
</div>
</div>
</div>
<div id="method-i-crc" class="method-detail ">
<div class="method-heading">
<span class="method-name">crc</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns CRC value of the uncompressed data.</p>
<div class="method-source-code" id="crc-source">
<pre>static VALUE
rb_gzfile_crc(VALUE obj)
{
return rb_uint2inum(get_gzfile(obj)->crc);
}</pre>
</div>
</div>
</div>
<div id="method-i-finish" class="method-detail ">
<div class="method-heading">
<span class="method-name">finish</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Closes the <a href="GzipFile.html"><code>GzipFile</code></a> object. Unlike <a href="GzipFile.html#method-i-close"><code>Zlib::GzipFile#close</code></a>, this method never calls the close method of the associated <a href="../IO.html"><code>IO</code></a> object. Returns the associated <a href="../IO.html"><code>IO</code></a> object.</p>
<div class="method-source-code" id="finish-source">
<pre>static VALUE
rb_gzfile_finish(VALUE obj)
{
struct gzfile *gz = get_gzfile(obj);
VALUE io;
io = gz->io;
gzfile_close(gz, 0);
return io;
}</pre>
</div>
</div>
</div>
<div id="method-i-level" class="method-detail ">
<div class="method-heading">
<span class="method-name">level</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns compression level.</p>
<div class="method-source-code" id="level-source">
<pre>static VALUE
rb_gzfile_level(VALUE obj)
{
return INT2FIX(get_gzfile(obj)->level);
}</pre>
</div>
</div>
</div>
<div id="method-i-mtime" class="method-detail ">
<div class="method-heading">
<span class="method-name">mtime</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns last modification time recorded in the gzip file header.</p>
<div class="method-source-code" id="mtime-source">
<pre>static VALUE
rb_gzfile_mtime(VALUE obj)
{
return rb_time_new(get_gzfile(obj)->mtime, (time_t)0);
}</pre>
</div>
</div>
</div>
<div id="method-i-orig_name" class="method-detail ">
<div class="method-heading">
<span class="method-name">orig_name</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns original filename recorded in the gzip file header, or <code>nil</code> if original filename is not present.</p>
<div class="method-source-code" id="orig_name-source">
<pre>static VALUE
rb_gzfile_orig_name(VALUE obj)
{
VALUE str = get_gzfile(obj)->orig_name;
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
return str;
}</pre>
</div>
</div>
</div>
<div id="method-i-os_code" class="method-detail ">
<div class="method-heading">
<span class="method-name">os_code</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns OS code number recorded in the gzip file header.</p>
<div class="method-source-code" id="os_code-source">
<pre>static VALUE
rb_gzfile_os_code(VALUE obj)
{
return INT2FIX(get_gzfile(obj)->os_code);
}</pre>
</div>
</div>
</div>
<div id="method-i-sync" class="method-detail ">
<div class="method-heading">
<span class="method-name">sync</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Same as <a href="../IO.html#method-i-sync"><code>IO#sync</code></a></p>
<div class="method-source-code" id="sync-source">
<pre>static VALUE
rb_gzfile_sync(VALUE obj)
{
return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse;
}</pre>
</div>
</div>
</div>
<div id="method-i-sync-3D" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
sync = flag
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Same as <a href="../IO.html"><code>IO</code></a>. If flag is <code>true</code>, the associated <a href="../IO.html"><code>IO</code></a> object must respond to the <code>flush</code> method. While <code>sync</code> mode is <code>true</code>, the compression ratio decreases sharply.</p>
<div class="method-source-code" id="sync-3D-source">
<pre>static VALUE
rb_gzfile_set_sync(VALUE obj, VALUE mode)
{
struct gzfile *gz = get_gzfile(obj);
if (RTEST(mode)) {
gz->z.flags |= GZFILE_FLAG_SYNC;
}
else {
gz->z.flags &= ~GZFILE_FLAG_SYNC;
}
return mode;
}</pre>
</div>
</div>
</div>
<div id="method-i-to_io" class="method-detail ">
<div class="method-heading">
<span class="method-name">to_io</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Same as <a href="../IO.html"><code>IO</code></a>.</p>
<div class="method-source-code" id="to_io-source">
<pre>static VALUE
rb_gzfile_to_io(VALUE obj)
{
return get_gzfile(obj)->io;
}</pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>