Class: LZMA::Encoder
- Inherits:
-
Struct
- Object
- Struct
- LZMA::Encoder
- Defined in:
- lib/extlzma.rb
Constant Summary collapse
- BLOCKSIZE =
256 KiB
256 * 1024
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
154 155 156 157 158 159 |
# File 'lib/extlzma.rb', line 154 def initialize(context, outport) super(context, outport, StringIO.new("".force_encoding(Encoding::BINARY)), "".force_encoding(Encoding::BINARY), [1]) self.class.method(:finalizer_regist).(self, context, outport, writebuf, workbuf, status) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
151 152 153 |
# File 'lib/extlzma.rb', line 151 def context @context end |
#outport ⇒ Object
Returns the value of attribute outport
151 152 153 |
# File 'lib/extlzma.rb', line 151 def outport @outport end |
#status ⇒ Object
Returns the value of attribute status
151 152 153 |
# File 'lib/extlzma.rb', line 151 def status @status end |
#workbuf ⇒ Object
Returns the value of attribute workbuf
151 152 153 |
# File 'lib/extlzma.rb', line 151 def workbuf @workbuf end |
#writebuf ⇒ Object
Returns the value of attribute writebuf
151 152 153 |
# File 'lib/extlzma.rb', line 151 def writebuf @writebuf end |
Instance Method Details
#close ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/extlzma.rb', line 179 def close if eof? raise "already closed stream - #{inspect}" end self.class.method(:finalizer_close).(context, outport, workbuf) status[0] = nil nil end |
#eof ⇒ Object Also known as: eof?
191 192 193 |
# File 'lib/extlzma.rb', line 191 def eof !status[0] end |
#write(buf) ⇒ Object Also known as: <<
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/extlzma.rb', line 161 def write(buf) writebuf.rewind writebuf.string.clear writebuf << buf until writebuf.string.empty? s = context.code(writebuf.string, workbuf, BLOCKSIZE, 0) unless s == 0 Utils.raise_err s end outport << workbuf workbuf.clear end self end |