class Arachni::Support::Buffer::AutoFlush
A buffer implementation which flushes itself when it gets full or a number of push attempts is reached between flushes.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Attributes
max_pushes[R]
Public Class Methods
new( max_size = nil, max_pushes = nil, type = Array )
click to toggle source
@param [Integer] max_size
Maximum buffer size -- a flush will be triggered when that limit is reached.
@param [Integer] max_pushes
Maximum number of pushes between flushes.
@param [#<<, #|, clear, size, empty?] type
Internal storage class to use.
Calls superclass method
# File lib/arachni/support/buffer/autoflush.rb, line 27 def initialize( max_size = nil, max_pushes = nil, type = Array ) super( max_size, type ) @max_pushes = max_pushes @pushes = 0 end
Public Instance Methods
<<( *args )
click to toggle source
Calls superclass method
# File lib/arachni/support/buffer/autoflush.rb, line 34 def <<( *args ) super( *args ) ensure handle_push end
batch_push( *args )
click to toggle source
Calls superclass method
# File lib/arachni/support/buffer/autoflush.rb, line 40 def batch_push( *args ) super( *args ) ensure handle_push end
flush()
click to toggle source
Calls superclass method
# File lib/arachni/support/buffer/autoflush.rb, line 46 def flush super ensure @pushes = 0 end
Private Instance Methods
flush?()
click to toggle source
# File lib/arachni/support/buffer/autoflush.rb, line 59 def flush? !!(full? || push_limit_reached?) end
handle_push()
click to toggle source
# File lib/arachni/support/buffer/autoflush.rb, line 54 def handle_push @pushes += 1 flush if flush? end
push_limit_reached?()
click to toggle source
# File lib/arachni/support/buffer/autoflush.rb, line 63 def push_limit_reached? max_pushes && @pushes >= max_pushes end