Class: LZMA::Decoder
- Inherits:
-
Struct
- Object
- Struct
- LZMA::Decoder
- 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.
-
#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 = "".force_encoding(Encoding::BINARY)) ⇒ Object
Constructor Details
#initialize(context, inport) ⇒ Decoder
Returns a new instance of Decoder.
237 238 239 240 241 242 |
# File 'lib/extlzma.rb', line 237 def initialize(context, inport) super context, inport, "".force_encoding(Encoding::BINARY), StringIO.new("".force_encoding(Encoding::BINARY)), :ready end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
234 235 236 |
# File 'lib/extlzma.rb', line 234 def context @context end |
#inport ⇒ Object
Returns the value of attribute inport
234 235 236 |
# File 'lib/extlzma.rb', line 234 def inport @inport end |
#readbuf ⇒ Object
Returns the value of attribute readbuf
234 235 236 |
# File 'lib/extlzma.rb', line 234 def readbuf @readbuf end |
#status ⇒ Object
Returns the value of attribute status
234 235 236 |
# File 'lib/extlzma.rb', line 234 def status @status end |
#workbuf ⇒ Object
Returns the value of attribute workbuf
234 235 236 |
# File 'lib/extlzma.rb', line 234 def workbuf @workbuf end |
Instance Method Details
#close ⇒ Object
269 270 271 272 273 274 |
# File 'lib/extlzma.rb', line 269 def close self.status = nil workbuf.rewind workbuf.string.clear nil end |
#eof ⇒ Object Also known as: eof?
263 264 265 |
# File 'lib/extlzma.rb', line 263 def eof !status && workbuf.eof? end |
#read(size = nil, buf = "".force_encoding(Encoding::BINARY)) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/extlzma.rb', line 244 def read(size = nil, buf = "".force_encoding(Encoding::BINARY)) buf.clear size = size.to_i if size return buf if size == 0 tmp = "".force_encoding(Encoding::BINARY) while !eof && (size.nil? || size > 0) if workbuf.eof? fetch or break end workbuf.read(size, tmp) or break buf << tmp size -= tmp.bytesize if size end (buf.empty? ? nil : buf) end |