Class: Zlib::ZStream
- Defined in:
- lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb
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
Returns a new instance of ZStream.
54 55 56 57 58 59 60 61 62 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 54 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.
64 65 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 64 def adler end |
#avail_in ⇒ Object
Returns the number of bytes read. Normally 0 since all bytes are read at once.
68 69 70 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 68 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.
73 74 75 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 73 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.
78 79 80 81 82 83 84 85 86 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 78 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
89 90 91 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 89 def close @closed = true end |
#closed? ⇒ Boolean
True if stream closed, otherwise False.
94 95 96 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 94 def closed? @closed end |
#data_type ⇒ Object
Best guess of input data, one of Zlib::BINARY, Zlib::ASCII, or Zlib::UNKNOWN
99 100 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 99 def data_type end |
#end ⇒ Object
See close
103 104 105 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 103 def end close end |
#ended? ⇒ Boolean
See closed?
108 109 110 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 108 def ended? closed? end |
#finish ⇒ Object
Finishes the stream, flushes output buffer, implemented by child classes
113 114 115 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 113 def finish close end |
#finished? ⇒ Boolean
True if stream is finished, otherwise False
118 119 120 121 122 123 124 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 118 def finished? if @finished.nil? then false else @finished end end |
#flush_next_in ⇒ Object
Flushes input buffer and returns the data therein.
127 128 129 130 131 132 133 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 127 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
136 137 138 139 140 141 142 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 136 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.
145 146 147 148 149 150 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 145 def reset @out_pos = -1 @in_pos = -1 @input_buffer = [] @output_buffer = [] end |
#stream_end? ⇒ Boolean
See finished.
153 154 155 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 153 def stream_end? finished? end |
#total_in ⇒ Object
Size of input buffer.
158 159 160 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 158 def total_in @input_buffer.length end |
#total_out ⇒ Object
Size of output buffer.
163 164 165 |
# File 'lib/motion-bundler/mocks/zliby-0.0.5/zlib.rb', line 163 def total_out @output_buffer.length end |