Class: RHC::Vendor::Zlib::ZStream
Direct Known Subclasses
Instance Method Summary collapse
-
#adler ⇒ Object
Returns the adler-32 checksum of the input data.
-
#avail_in ⇒ Object
Returns the number of bytes read.
-
#avail_out ⇒ Object
Returns number of free bytes in the output buffer.
-
#avail_out=(size) ⇒ Object
Allocates size bytes in output buffer.
-
#close ⇒ Object
Closes stream.
-
#closed? ⇒ Boolean
True if stream closed, otherwise False.
-
#data_type ⇒ Object
Best guess of input data, one of Zlib::BINARY, Zlib::ASCII, or Zlib::UNKNOWN.
-
#end ⇒ Object
See close.
-
#ended? ⇒ Boolean
See closed?.
-
#finish ⇒ Object
Finishes the stream, flushes output buffer, implemented by child classes.
-
#finished? ⇒ Boolean
True if stream is finished, otherwise False.
-
#flush_next_in ⇒ Object
Flushes input buffer and returns the data therein.
-
#flush_next_out ⇒ Object
Flushes the output buffer and returns all the data.
-
#initialize ⇒ ZStream
constructor
A new instance of ZStream.
-
#reset ⇒ Object
Reset stream.
-
#stream_end? ⇒ Boolean
See finished.
-
#total_in ⇒ Object
Size of input buffer.
-
#total_out ⇒ Object
Size of output buffer.
Constructor Details
#initialize ⇒ ZStream
57 58 59 60 61 62 63 64 65 |
# File 'lib/rhc/vendor/zliby.rb', line 57 def initialize @input_buffer = [] @output_buffer = [] @out_pos = -1 @in_pos = -1 @bit_bucket = 0 @bit_count = 0 end |
Instance Method Details
#adler ⇒ Object
Returns the adler-32 checksum of the input data.
67 68 |
# File 'lib/rhc/vendor/zliby.rb', line 67 def adler end |
#avail_in ⇒ Object
Returns the number of bytes read. Normally 0 since all bytes are read at once.
71 72 73 |
# File 'lib/rhc/vendor/zliby.rb', line 71 def avail_in @input_buffer.length - @in_pos end |
#avail_out ⇒ Object
Returns number of free bytes in the output buffer. As the output buffer is self expanding this normally returns 0.
76 77 78 |
# File 'lib/rhc/vendor/zliby.rb', line 76 def avail_out @output_buffer.length - @out_pos end |
#avail_out=(size) ⇒ Object
Allocates size bytes in output buffer. If size < avail_out it truncates the buffer.
81 82 83 84 85 86 87 88 89 |
# File 'lib/rhc/vendor/zliby.rb', line 81 def avail_out= size size.times do if size > avail_out @output_buffer.push nil else @output_buffer.pop end end end |
#close ⇒ Object
Closes stream. Further operations will raise Zlib::StreamError
92 93 94 |
# File 'lib/rhc/vendor/zliby.rb', line 92 def close @closed = true end |
#closed? ⇒ Boolean
True if stream closed, otherwise False.
97 98 99 |
# File 'lib/rhc/vendor/zliby.rb', line 97 def closed? @closed end |
#data_type ⇒ Object
Best guess of input data, one of Zlib::BINARY, Zlib::ASCII, or Zlib::UNKNOWN
102 103 |
# File 'lib/rhc/vendor/zliby.rb', line 102 def data_type end |
#ended? ⇒ Boolean
See closed?
111 112 113 |
# File 'lib/rhc/vendor/zliby.rb', line 111 def ended? closed? end |
#finish ⇒ Object
Finishes the stream, flushes output buffer, implemented by child classes
116 117 118 |
# File 'lib/rhc/vendor/zliby.rb', line 116 def finish close end |
#finished? ⇒ Boolean
True if stream is finished, otherwise False
121 122 123 124 125 126 127 |
# File 'lib/rhc/vendor/zliby.rb', line 121 def finished? if @finished.nil? then false else @finished end end |
#flush_next_in ⇒ Object
Flushes input buffer and returns the data therein.
130 131 132 133 134 135 136 |
# File 'lib/rhc/vendor/zliby.rb', line 130 def flush_next_in @in_pos = @input_buffer.length @finished = true ret = @input_buffer.pack("c*") @input_buffer = [] ret end |
#flush_next_out ⇒ Object
Flushes the output buffer and returns all the data
139 140 141 142 143 144 145 |
# File 'lib/rhc/vendor/zliby.rb', line 139 def flush_next_out @out_pos = @output_buffer.length @finished = true ret = @output_buffer.pack("c*") @output_buffer = [] ret end |
#reset ⇒ Object
Reset stream. Input and Output buffers are reset.
148 149 150 151 152 153 |
# File 'lib/rhc/vendor/zliby.rb', line 148 def reset @out_pos = -1 @in_pos = -1 @input_buffer = [] @output_buffer = [] end |
#stream_end? ⇒ Boolean
See finished.
156 157 158 |
# File 'lib/rhc/vendor/zliby.rb', line 156 def stream_end? finished? end |
#total_in ⇒ Object
Size of input buffer.
161 162 163 |
# File 'lib/rhc/vendor/zliby.rb', line 161 def total_in @input_buffer.length end |
#total_out ⇒ Object
Size of output buffer.
166 167 168 |
# File 'lib/rhc/vendor/zliby.rb', line 166 def total_out @output_buffer.length end |