Class: Nessana::Filter
- Inherits:
-
Hash
- Object
- Hash
- Nessana::Filter
- Defined in:
- lib/nessana/filter.rb
Instance Method Summary collapse
- #applies_to?(vulnerability) ⇒ Boolean
-
#initialize(hash) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(hash) ⇒ Filter
Returns a new instance of Filter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/nessana/filter.rb', line 7 def initialize(hash) super fixed_hash = hash.map do |key, value| [key.to_sym, value] end.to_h merge!(fixed_hash) end |
Instance Method Details
#applies_to?(vulnerability) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nessana/filter.rb', line 17 def applies_to?(vulnerability) each do |key, value| method = key.to_sym return false unless vulnerability.respond_to?(method) case value when Regexp return true if vulnerability.send(method).to_s =~ value else return true if vulnerability.send(method).to_s == value end end false end |