Class: LZMA::Decoder
- Inherits:
-
Struct
- Object
- Struct
- LZMA::Decoder
- Defined in:
- lib/extlzma2/decoder.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#inport ⇒ Object
Returns the value of attribute inport.
-
#readbuf ⇒ Object
Returns the value of attribute readbuf.
-
#status ⇒ Object
Returns the value of attribute status.
-
#workbuf ⇒ Object
Returns the value of attribute workbuf.
Instance Method Summary collapse
- #close ⇒ Object
- #eof ⇒ Object (also: #eof?)
-
#initialize(context, inport) ⇒ Decoder
constructor
A new instance of Decoder.
- #read(size = nil, buf = String.new) ⇒ Object
Constructor Details
#initialize(context, inport) ⇒ Decoder
Returns a new instance of Decoder.
9 10 11 |
# File 'lib/extlzma2/decoder.rb', line 9 def initialize(context, inport) super(context, inport, String.new, StringIO.new(String.new), :ready) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
6 7 8 |
# File 'lib/extlzma2/decoder.rb', line 6 def context @context end |
#inport ⇒ Object
Returns the value of attribute inport
6 7 8 |
# File 'lib/extlzma2/decoder.rb', line 6 def inport @inport end |
#readbuf ⇒ Object
Returns the value of attribute readbuf
6 7 8 |
# File 'lib/extlzma2/decoder.rb', line 6 def readbuf @readbuf end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/extlzma2/decoder.rb', line 6 def status @status end |
#workbuf ⇒ Object
Returns the value of attribute workbuf
6 7 8 |
# File 'lib/extlzma2/decoder.rb', line 6 def workbuf @workbuf end |
Instance Method Details
#close ⇒ Object
36 37 38 39 40 41 |
# File 'lib/extlzma2/decoder.rb', line 36 def close self.status = nil workbuf.rewind workbuf.string.clear nil end |
#eof ⇒ Object Also known as: eof?
30 31 32 |
# File 'lib/extlzma2/decoder.rb', line 30 def eof !status && workbuf.eof? end |
#read(size = nil, buf = String.new) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/extlzma2/decoder.rb', line 13 def read(size = nil, buf = String.new) buf.clear size = size.to_i if size return buf if size == 0 tmp = String.new while !eof && (size.nil? || size > 0) fetch or break if workbuf.eof? workbuf.read(size, tmp) or break buf << tmp size -= tmp.bytesize if size end buf end |