Class: HexaPDF::Filter::FlateDecode::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/filter/flate_decode.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Pool

Creates a new Zlib::Stream pool. A block must be given that returns a new Zlib::Stream instance.



52
53
54
55
# File 'lib/hexapdf/filter/flate_decode.rb', line 52

def initialize(&block)
  @creator = block
  @pool = []
end

Instance Method Details

#next_availableObject

Returns the next available stream of the pool, already reset to its initial state.



58
59
60
# File 'lib/hexapdf/filter/flate_decode.rb', line 58

def next_available
  @pool.find(-> { e = @creator.call; @pool << e; e }, &:finished?).tap(&:reset)
end