Method: Origami::Stream#encode!
- Defined in:
- lib/origami/stream.rb
#encode! ⇒ Object
Compress the stream data.
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/origami/stream.rb', line 349 def encode! return if encoded? filters = self.filters if filters.empty? @encoded_data = @data.dup return end unless filters.all?{|filter| filter.is_a?(Name)} raise InvalidStreamObjectError, "Invalid Filter type parameter" end dparams = decode_params @encoded_data = @data.dup (filters.length - 1).downto(0) do |layer| params = dparams[layer].is_a?(Dictionary) ? dparams[layer] : {} filter = filters[layer] # Handle Crypt filters. if filter == :Crypt raise Filter::Error, "Crypt filter must be the first filter" unless layer.zero? # Skip the Crypt filter. next end @encoded_data = encode_data(@encoded_data, filter, params) end self.Length = @encoded_data.length self end |