Class: Arachni::Support::LookUp::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/support/lookup/base.rb

Overview

This class is abstract.

Author:

Direct Known Subclasses

HashSet, Moolb

Constant Summary collapse

DEFAULT_OPTIONS =
{
    hasher: :hash
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • (:hasher) (Symbol)

    Method to call on the item to obtain its hash.



35
36
37
38
# File 'lib/arachni/support/lookup/base.rb', line 35

def initialize( options = {} )
    @options = DEFAULT_OPTIONS.merge( options )
    @hasher  = @options[:hasher].to_sym
end

Instance Method Details

#<<(item) ⇒ HashSet Also known as: add

Returns self.

Parameters:

  • item (#persistent_hash)

    Item to insert.

Returns:



45
46
47
48
# File 'lib/arachni/support/lookup/base.rb', line 45

def <<( item )
    @collection << calculate_hash( item )
    self
end

#clearObject



78
79
80
# File 'lib/arachni/support/lookup/base.rb', line 78

def clear
    @collection.clear
end

#delete(item) ⇒ HashSet

Returns self.

Parameters:

  • item (#persistent_hash)

    Item to delete.

Returns:



56
57
58
59
# File 'lib/arachni/support/lookup/base.rb', line 56

def delete( item )
    @collection.delete( calculate_hash( item ) )
    self
end

#empty?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/arachni/support/lookup/base.rb', line 70

def empty?
    @collection.empty?
end

#include?(item) ⇒ Bool

Parameters:

  • item (#persistent_hash)

    Item to check.

Returns:

  • (Bool)


66
67
68
# File 'lib/arachni/support/lookup/base.rb', line 66

def include?( item )
    @collection.include? calculate_hash( item )
end

#sizeObject



74
75
76
# File 'lib/arachni/support/lookup/base.rb', line 74

def size
    @collection.size
end