Class: Arachni::Support::Buffer::AutoFlush

Inherits:
Base show all
Defined in:
lib/arachni/support/buffer/autoflush.rb

Overview

A buffer implementation which flushes itself when it gets full or a number of push attempts is reached between flushes.

Author:

Instance Attribute Summary collapse

Attributes inherited from Base

#max_size

Instance Method Summary collapse

Methods inherited from Base

#empty?, #full?, #on_batch_push, #on_flush, #on_push, #size

Constructor Details

#initialize(max_size = nil, max_pushes = nil, type = Array) ⇒ AutoFlush

Returns a new instance of AutoFlush.

Parameters:

  • max_size (Integer) (defaults to: nil)

    Maximum buffer size – a flush will be triggered when that limit is reached.

  • max_pushes (Integer) (defaults to: nil)

    Maximum number of pushes between flushes.

  • type (#<<, #|, #clear, #size, #empty?) (defaults to: Array)

    Internal storage class to use.



37
38
39
40
41
42
# File 'lib/arachni/support/buffer/autoflush.rb', line 37

def initialize( max_size = nil, max_pushes = nil, type = Array )
    super( max_size, type )

    @max_pushes = max_pushes
    @pushes     = 0
end

Instance Attribute Details

#max_pushesObject (readonly)

Returns the value of attribute max_pushes.



28
29
30
# File 'lib/arachni/support/buffer/autoflush.rb', line 28

def max_pushes
  @max_pushes
end

Instance Method Details

#<<(*args) ⇒ Object



44
45
46
47
48
# File 'lib/arachni/support/buffer/autoflush.rb', line 44

def <<( *args )
    super( *args )
ensure
    handle_push
end

#batch_push(*args) ⇒ Object



50
51
52
53
54
# File 'lib/arachni/support/buffer/autoflush.rb', line 50

def batch_push( *args )
    super( *args )
ensure
    handle_push
end

#flushObject



56
57
58
59
60
# File 'lib/arachni/support/buffer/autoflush.rb', line 56

def flush
    super
ensure
    @pushes = 0
end