Class: LZMA::Encoder
- Inherits:
-
Struct
- Object
- Struct
- LZMA::Encoder
- Defined in:
- lib/extlzma2/encoder.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#outport ⇒ Object
Returns the value of attribute outport.
-
#status ⇒ Object
Returns the value of attribute status.
-
#workbuf ⇒ Object
Returns the value of attribute workbuf.
-
#writebuf ⇒ Object
Returns the value of attribute writebuf.
Instance Method Summary collapse
- #close ⇒ Object
- #eof ⇒ Object (also: #eof?)
-
#initialize(context, outport) ⇒ Encoder
constructor
A new instance of Encoder.
- #write(buf) ⇒ Object (also: #<<)
Constructor Details
#initialize(context, outport) ⇒ Encoder
Returns a new instance of Encoder.
9 10 11 12 |
# File 'lib/extlzma2/encoder.rb', line 9 def initialize(context, outport) super(context, outport, StringIO.new(String.new), String.new, [1]) self.class.method(:finalizer_regist).call(self, context, outport, writebuf, workbuf, status) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
6 7 8 |
# File 'lib/extlzma2/encoder.rb', line 6 def context @context end |
#outport ⇒ Object
Returns the value of attribute outport
6 7 8 |
# File 'lib/extlzma2/encoder.rb', line 6 def outport @outport end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/extlzma2/encoder.rb', line 6 def status @status end |
#workbuf ⇒ Object
Returns the value of attribute workbuf
6 7 8 |
# File 'lib/extlzma2/encoder.rb', line 6 def workbuf @workbuf end |
#writebuf ⇒ Object
Returns the value of attribute writebuf
6 7 8 |
# File 'lib/extlzma2/encoder.rb', line 6 def writebuf @writebuf end |
Instance Method Details
#close ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/extlzma2/encoder.rb', line 30 def close raise "already closed stream - #{inspect}" if eof? self.class.method(:finalizer_close).call(context, outport, workbuf) status[0] = nil nil end |
#eof ⇒ Object Also known as: eof?
40 41 42 |
# File 'lib/extlzma2/encoder.rb', line 40 def eof !status[0] end |
#write(buf) ⇒ Object Also known as: <<
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/extlzma2/encoder.rb', line 14 def write(buf) writebuf.rewind writebuf.string.clear writebuf << buf until writebuf.string.empty? s = context.code(writebuf.string, workbuf, self.class::BLOCKSIZE, 0) Utils.raise_err s unless s == 0 outport << workbuf workbuf.clear end self end |