Class: RangeScan::Matcher
- Inherits:
-
Object
- Object
- RangeScan::Matcher
- Defined in:
- lib/rangescan/matcher.rb
Instance Attribute Summary collapse
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
- #filter(results) ⇒ Object
-
#initialize(regexp) ⇒ Matcher
constructor
A new instance of Matcher.
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
#regexp ⇒ Object (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 |