class Arachni::Support::LookUp::Base
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com> @abstract
Constants
- DEFAULT_OPTIONS
Attributes
collection[R]
Public Class Methods
new( options = {} )
click to toggle source
@param [Hash] options @option options [Symbol] (:hasher)
Method to call on the item to obtain its hash.
# File lib/arachni/support/lookup/base.rb, line 27 def initialize( options = {} ) @options = DEFAULT_OPTIONS.merge( options ) @hasher = @options[:hasher].to_sym end
Public Instance Methods
<<( item )
click to toggle source
@param [#persistent_hash] item
Item to insert.
@return [HashSet]
`self`
# File lib/arachni/support/lookup/base.rb, line 37 def <<( item ) @collection << calculate_hash( item ) self end
Also aliased as: add
==( other )
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 77 def ==( other ) hash == other.hash end
any?()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 65 def any? !empty? end
clear()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 73 def clear @collection.clear end
delete( item )
click to toggle source
@param [#persistent_hash] item
Item to delete.
@return [HashSet]
`self`
# File lib/arachni/support/lookup/base.rb, line 48 def delete( item ) @collection.delete( calculate_hash( item ) ) self end
dup()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 85 def dup self.class.new( @options.dup ).tap { |c| c.collection = @collection.dup } end
empty?()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 61 def empty? @collection.empty? end
hash()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 81 def hash @collection.hash end
include?( item )
click to toggle source
@param [#persistent_hash] item
Item to check.
@return [Bool]
# File lib/arachni/support/lookup/base.rb, line 57 def include?( item ) @collection.include? calculate_hash( item ) end
size()
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 69 def size @collection.size end
Protected Instance Methods
collection=( c )
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 91 def collection=( c ) @collection = c end
Private Instance Methods
calculate_hash( item )
click to toggle source
# File lib/arachni/support/lookup/base.rb, line 97 def calculate_hash( item ) item.send @hasher end