class HexaPDF::StreamData

Parent

Container for stream data that is more complex than a string.

This helper class wraps all information necessary to read stream data by using a Fiber object (see HexaPDF::Filter). The underlying data either comes from an IO object, a file represented by its file name or a Fiber defined via a Proc object.

Additionally, the filter and decode_parms can be set to indicate that the data returned from the Fiber needs to be post-processed. The filter and decode_parms are automatically normalized to arrays on assignment to ease further processing.

Attributes

decode_parms[R]

The decoding parameters associated with the filter(s).

filter[R]

The filter(s) that need to be applied for getting the decoded stream data.

length[R]

The optional number of bytes to use starting from offset.

offset[R]

The optional offset into the bytes provided by source.

source[R]

The source.

Public Class Methods

new(io) → stream_data
new(str) → stream_data
new(proc) → stream_data
new { block } → stream_data

Creates a new StreamData object for the given source and with the given options.

The source can be:

  • An IO stream which is read starting from a specific offset for a specific length

  • A string which is interpreted as a file name and read starting from a specific offset

  • and for a specific length

  • A Proc object (that is converted to a Fiber when needed) in which case the offset and value is ignored. The Proc object can also be passed by using a block.

Public Instance Methods

==(other)

Returns whether this stream data object is equal to the other stream data object.

fiber(chunk_size = 0)

Returns a Fiber for getting at the data of the stream represented by this object.