Sha256: 11c836b33b978b76abb425bd1a28c68a7993e22bdaeaa02d2e0c93fbf9283cfa

Contents?: true

Size: 485 Bytes

Versions: 9

Compression:

Stored size: 485 Bytes

Contents

require "attributable"

module Metamorpher
  module Matcher
    class Match
      extend Attributable
      attributes :root, substitution: {}

      def matches?
        true
      end

      def match_for(variable)
        substitution[variable.name]
      end

      def combine(combinee)
        if combinee.matches?
          Match.new(root: root, substitution: combinee.substitution.merge(substitution))
        else
          NoMatch.new
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
metamorpher-0.2.6 lib/metamorpher/matcher/match.rb
metamorpher-0.2.5 lib/metamorpher/matcher/match.rb
metamorpher-0.2.4 lib/metamorpher/matcher/match.rb
metamorpher-0.2.3 lib/metamorpher/matcher/match.rb
metamorpher-0.2.2 lib/metamorpher/matcher/match.rb
metamorpher-0.2.1 lib/metamorpher/matcher/match.rb
metamorpher-0.2.0 lib/metamorpher/matcher/match.rb
metamorpher-0.1.1 lib/metamorpher/matcher/match.rb
metamorpher-0.1.0 lib/metamorpher/matcher/match.rb