Sha256: 3f03fb1d00a2626dba0c1b64834bfb76230003573f80aa4477d33c6bab46cfb2

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

#encoding: utf-8

# the main module
module TheArrayComparator
  # the available strategies
  module Strategies
    #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

2 entries across 2 versions & 1 rubygems

Version Path
the_array_comparator-0.2.0 lib/the_array_comparator/strategies/base.rb
the_array_comparator-0.1.1 lib/the_array_comparator/strategies/base.rb