Class: RangeScan::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rangescan/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp) ⇒ Matcher

Returns a new instance of Matcher.



7
8
9
# File 'lib/rangescan/matcher.rb', line 7

def initialize(regexp)
  @regexp = Regexp.new(regexp)
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



5
6
7
# File 'lib/rangescan/matcher.rb', line 5

def regexp
  @regexp
end

Instance Method Details

#filter(results) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/rangescan/matcher.rb', line 11

def filter(results)
  results.select do |result|
    body = result.dig(:body) || ""
    begin
      body =~ regexp
    rescue ArgumentError, Encoding::CompatibilityError
      false
    end
  end
end