Class: RHC::Vendor::Zlib::ZStream

Inherits:
Object
  • Object
show all
Defined in:
lib/rhc/vendor/zliby.rb

Direct Known Subclasses

Inflate

Instance Method Summary collapse

Constructor Details

#initializeZStream



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

#adlerObject

Returns the adler-32 checksum of the input data.



67
68
# File 'lib/rhc/vendor/zliby.rb', line 67

def adler
end

#avail_inObject

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_outObject

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

#closeObject

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_typeObject

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

#endObject

See close



106
107
108
# File 'lib/rhc/vendor/zliby.rb', line 106

def end
  close
end

#ended?Boolean

See closed?



111
112
113
# File 'lib/rhc/vendor/zliby.rb', line 111

def ended?
  closed?
end

#finishObject

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_inObject

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_outObject

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

#resetObject

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_inObject

Size of input buffer.



161
162
163
# File 'lib/rhc/vendor/zliby.rb', line 161

def total_in
  @input_buffer.length
end

#total_outObject

Size of output buffer.



166
167
168
# File 'lib/rhc/vendor/zliby.rb', line 166

def total_out
  @output_buffer.length
end