Sha256: 34af68078ea5c571bcfdafc484808b43fa1169427b2d3fad10d563cd7c4d7b8f

Contents?: true

Size: 1009 Bytes

Versions: 5

Compression:

Stored size: 1009 Bytes

Contents

#encoding: utf-8

# the main module
module TheArrayComparator
  # the available strategies
  module SearchingStrategies
    # strategy contains substring
    class ContainsAllWithSubstringSearch < Base

      # Create a new instance of strategy
      #
      # @see Base
      def initialize(sample=Sample.new)
        super
      end

      # Check the keywords with the data
      #
      # @return [Boolean]
      #   The result of the check
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
the_array_comparator-0.5.0 lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb
the_array_comparator-0.4.0 lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb
the_array_comparator-0.3.4 lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb
the_array_comparator-0.3.1 lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb
the_array_comparator-0.3.0 lib/the_array_comparator/searching_strategies/contains_all_with_substring_search.rb