Class: PDF::Reader::Stream
- Inherits:
-
Object
- Object
- PDF::Reader::Stream
- Defined in:
- lib/pdf/reader/stream.rb
Overview
An internal PDF::Reader class that represents a stream object from a PDF. Stream objects have 2 components, a dictionary that describes the content (size, compression, etc) and a stream of bytes.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(hash, data) ⇒ Stream
constructor
Creates a new stream with the specified dictionary and data.
-
#unfiltered_data ⇒ Object
apply this streams filters to its data and return the result.
Constructor Details
#initialize(hash, data) ⇒ Stream
Creates a new stream with the specified dictionary and data. The dictionary should be a standard ruby hash, the data should be a standard ruby string.
47 48 49 50 51 |
# File 'lib/pdf/reader/stream.rb', line 47 def initialize(hash, data) @hash = TypeCheck.cast_to_pdf_dict!(hash) #: Hash[Symbol, untyped] @data = data @udata = nil #: String | nil end |
Instance Attribute Details
#data ⇒ Object
41 42 43 |
# File 'lib/pdf/reader/stream.rb', line 41 def data @data end |
#hash ⇒ Object
38 39 40 |
# File 'lib/pdf/reader/stream.rb', line 38 def hash @hash end |
Instance Method Details
#unfiltered_data ⇒ Object
apply this streams filters to its data and return the result.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pdf/reader/stream.rb', line 55 def unfiltered_data return @udata if @udata @udata = data.dup if hash.has_key?(:Filter) = [] if hash.has_key?(:DecodeParms) if hash[:DecodeParms].is_a?(Hash) = [hash[:DecodeParms]] else = hash[:DecodeParms] end end Array(hash[:Filter]).each_with_index do |filter, index| @udata = Filter.with(filter, [index] || {}).filter(@udata) end end @udata end |