Sha256: cf9acd6f44ced77c82475c758ee1805f7761e0534d20e695f36767085cc85d63
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require_relative 'relation' module MiniKraken module Core # A relation that is parametrized with generic formal arguments # and a goal template expression. class DefRelation < Relation # @return [Array<FormalArg>] formal arguments of this DefRelation attr_reader :formals # @return [GoalTemplate] goal template attr_reader :goal_template # @param aName [String] name of def relation # @param aGoalTemplate [GoalTemplate] # @param theFormals [Array<FormalArg>] def initialize(aName, aGoalTemplate, theFormals, alternateName = nil) super(aName, alternateName) @formals = validated_formals(theFormals) @goal_template = validated_goal_template(aGoalTemplate) freeze end # Number of arguments for the relation. # @return [Integer] def arity formals.size end # @param actuals [Array<Term>] A two-elements array # @param anEnv [Vocabulary] A vocabulary object # @return [Fiber<Outcome>] A Fiber(-like) instance that yields Outcomes def solver_for(actuals, anEnv) goal = goal_template.instantiate(formals, actuals) goal.attain(anEnv) end private def validated_formals(theFormals) theFormals end def validated_goal_template(aGoalTemplate) raise StandardError unless aGoalTemplate aGoalTemplate end end # class end # module end # module
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mini_kraken-0.2.04 | lib/mini_kraken/core/def_relation.rb |
mini_kraken-0.2.03 | lib/mini_kraken/core/def_relation.rb |