Class: TheArrayComparator::SearchingStrategies::ContainsAllWithSubstringSearch
- Inherits:
-
Base
- Object
- Base
- TheArrayComparator::SearchingStrategies::ContainsAllWithSubstringSearch
- Defined in:
- lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb
Overview
strategy contains substring
Instance Method Summary collapse
-
#initialize(sample = Sample.new) ⇒ ContainsAllWithSubstringSearch
constructor
Create a new instance of strategy.
-
#success? ⇒ Boolean
Check the keywords with the data.
Constructor Details
#initialize(sample = Sample.new) ⇒ ContainsAllWithSubstringSearch
Create a new instance of strategy
13 14 15 |
# File 'lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb', line 13 def initialize(sample=Sample.new) super end |
Instance Method Details
#success? ⇒ Boolean
Check the keywords with the data
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb', line 21 def success? return true if @keywords.blank? and @data.blank? #return true if @data.all? do |line| # #does a keyword match and it is not an the exception list # binding.pry # @keywords.all?{ |k| line[k] } and not @exceptions.any?{ |e| line[e] } #end return true if @keywords.all? do |word| #does a keyword match and it is not an the exception list @data.any?{ |line| line[word] and not @exceptions.any?{ |e| line[e] } } end false end |