Class: TheArrayComparator::SearchingStrategies::ContainsNotWithSubstringSearch

Inherits:
Base
  • Object
show all
Defined in:
lib/the_array_comparator/searching_strategies/contains_not_with_substring_search.rb

Overview

strategy not contains substring

Instance Method Summary collapse

Constructor Details

#initialize(sample = Sample.new) ⇒ ContainsNotWithSubstringSearch

Create a new instance of strategy

See Also:



13
14
15
# File 'lib/the_array_comparator/searching_strategies/contains_not_with_substring_search.rb', line 13

def initialize(sample=Sample.new)
  super
end

Instance Method Details

#success?Boolean

Check the keywords with the data

Returns:

  • (Boolean)

    The result of the check



21
22
23
24
25
26
27
28
29
30
# File 'lib/the_array_comparator/searching_strategies/contains_not_with_substring_search.rb', line 21

def success?
  return false if @keywords.blank? and @data.blank?

  return true if @data.all? do |line| 
    #if a keyword is found, check if there's an exception
    @keywords.none?{ |k| line[k] } or @exceptions.any?{ |e| line[e] }
  end

  false
end