Sha256: 2f7308ecad0db1ec809d6e85dfa4faaf9d20c828c9fe455e6bb99388b329138d

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

module Adhearsion
  module MenuDSL
    class CalculatedMatch

      def self.failed_match!(pattern, query, match_payload)
        new :pattern => pattern, :query => query, :match_payload => match_payload
      end

      attr_reader :match_payload, :potential_matches, :exact_matches, :pattern, :query, :block

      def initialize(options = {})
        @pattern, @query, @match_payload, @block = options.values_at :pattern, :query, :match_payload, :block
        @potential_matches  = options[:potential_matches] ? Array(options[:potential_matches]) : []
        @exact_matches      = options[:exact_matches] ? Array(options[:exact_matches]) : []
      end

      def exact_match?
        exact_matches.any?
      end

      def potential_match?
        potential_matches.any?
      end

      def failed_match?
        !(potential_match? || exact_match?)
      end

      def type_of_match
        if exact_match?
          :exact
        elsif potential_match?
          :potential
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adhearsion-2.0.0.rc4 lib/adhearsion/menu_dsl/calculated_match.rb
adhearsion-2.0.0.rc3 lib/adhearsion/menu_dsl/calculated_match.rb
adhearsion-2.0.0.rc2 lib/adhearsion/menu_dsl/calculated_match.rb
adhearsion-2.0.0.rc1 lib/adhearsion/menu_dsl/calculated_match.rb