Sha256: 9086435cb50a628cbca8915acd268b3761b14b79ec45db221d3f214b1cf42071

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

#encoding: utf-8

# the main module
module TheArrayComparator
  # the available strategies
  module SearchingStrategies
    #base class for strategies
    class Base

      # Create a new instance of strategy
      #
      # @param [Sample] sample
      #    the probe which should be used for the check
      #
      # @return [Object] 
      #   the strategy
      def initialize(sample=Sample.new)
        @data = sample.data
        @keywords = sample.keywords
        @exceptions = sample.exceptions
        @tag = sample.tag
      end

      # Check the keywords with the data
      #
      # @note
      #   needs to be implemented by the concrete strategy
      # @raise [RuntimeError]
      #   error when not implemented by strategy
      def success?
        raise Exceptions::IncompatibleComparator, "The chosen comparator is incompatible, Please check the documentation for comparator strategies on how to build a compatible one."
      end

      private 

      def warning_unsupported_exceptions
        warn "Exceptions are not supported by this strategy." unless @exceptions.blank?
      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/base.rb
the_array_comparator-0.4.0 lib/the_array_comparator/searching_strategies/base.rb
the_array_comparator-0.3.4 lib/the_array_comparator/searching_strategies/base.rb
the_array_comparator-0.3.1 lib/the_array_comparator/searching_strategies/base.rb
the_array_comparator-0.3.0 lib/the_array_comparator/searching_strategies/base.rb