class Arachni::Support::Buffer::Base
Base
buffer class to be extended by more specialised implementation.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Attributes
max_size[R]
@return [Integer] Maximum buffer size.
Public Class Methods
new( max_size = nil, type = Array )
click to toggle source
@param [Integer] max_size
Maximum buffer size -- won't be enforced.
@param [#<<, #|, clear, size
, empty?
] type
Internal storage class to use.
Calls superclass method
Arachni::Support::Mixins::Observable::new
# File lib/arachni/support/buffer/base.rb, line 39 def initialize( max_size = nil, type = Array ) super() @buffer = type.new @max_size = max_size end
Public Instance Methods
<<( obj )
click to toggle source
@note Calls {#on_push} blocks with the given object and pushes an object
to the buffer.
@param [Object] obj
Object to push.
# File lib/arachni/support/buffer/base.rb, line 50 def <<( obj ) notify_on_push obj @buffer << obj self end
Also aliased as: push
batch_push( list )
click to toggle source
@note Calls {#on_batch_push} blocks with the given list and merges the
buffer with the contents of a list.
@param [#|] list
List of objects
# File lib/arachni/support/buffer/base.rb, line 62 def batch_push( list ) notify_on_batch_push list @buffer |= list self end
empty?()
click to toggle source
@return [Bool]
`true` if the buffer is empty, `false` otherwise.
# File lib/arachni/support/buffer/base.rb, line 76 def empty? @buffer.empty? end
flush()
click to toggle source
@note Calls {#on_flush} blocks with the buffer and then empties it.
@return current buffer
# File lib/arachni/support/buffer/base.rb, line 89 def flush buffer = @buffer.dup notify_on_flush buffer buffer ensure @buffer.clear end
full?()
click to toggle source
@return [Bool]
`true` if the buffer is full, `false` otherwise.
# File lib/arachni/support/buffer/base.rb, line 82 def full? !!(max_size && size >= max_size) end
size()
click to toggle source
@return [Integer]
Number of object in the buffer.
# File lib/arachni/support/buffer/base.rb, line 70 def size @buffer.size end