class CVE::Filter

Attributes

history[RW]
history_size[RW]

Public Class Methods

new(history_size=100) click to toggle source
# File lib/cve_crawler/cve_filter.rb, line 3
def initialize(history_size=100)
  @history = []
  @history_size = history_size
end

Public Instance Methods

cve_exists?(identifier) click to toggle source
# File lib/cve_crawler/cve_filter.rb, line 18
def cve_exists?(identifier)
  return true if @history.include?(identifier)

  @history << identifier
  false
end
filter(contents) click to toggle source
# File lib/cve_crawler/cve_filter.rb, line 10
def filter(contents)
  return true unless contents.is_a?(Vulnerability)
  return true if cve_exists?(contents.identifier)

  history_check_limit
  false
end
history_check_limit() click to toggle source
# File lib/cve_crawler/cve_filter.rb, line 25
def history_check_limit
  if @history.length > @history_size
    @history = @history.drop(@history.length - @history_size)
  end
end
inspect() click to toggle source
# File lib/cve_crawler/cve_filter.rb, line 31
def inspect
  "#<CVE::Filter history=#{@history.count} limit=#{@history_size}>"
end