Class: MiniKraken::Core::ParametrizedTerm
- Defined in:
- lib/mini_kraken/core/parametrized_term.rb
Overview
A specialization of Term class for objects that take arguments.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actuals ⇒ Array<Term>
readonly
The actual aguments of the goal.
-
#specification ⇒ Specification
readonly
The specification that must be invoked with arguments.
Instance Method Summary collapse
-
#dup_cond(substitutions) ⇒ Term
Make a copy of self with all the variable reference being replaced by the corresponding value in the Hash.
-
#initialize(theSpecification, theArgs) ⇒ ParametrizedTerm
constructor
Constructor.
- #initialize_copy(orig) ⇒ Object
Constructor Details
#initialize(theSpecification, theArgs) ⇒ ParametrizedTerm
Constructor.
19 20 21 22 23 24 |
# File 'lib/mini_kraken/core/parametrized_term.rb', line 19 def initialize(theSpecification, theArgs) super() @specification = validated_specification(theSpecification) args = specification.check_arity(theArgs) @actuals = validated_actuals(args) end |
Instance Attribute Details
#actuals ⇒ Array<Term> (readonly)
Returns The actual aguments of the goal.
14 15 16 |
# File 'lib/mini_kraken/core/parametrized_term.rb', line 14 def actuals @actuals end |
#specification ⇒ Specification (readonly)
Returns The specification that must be invoked with arguments.
11 12 13 |
# File 'lib/mini_kraken/core/parametrized_term.rb', line 11 def specification @specification end |
Instance Method Details
#dup_cond(substitutions) ⇒ Term
Make a copy of self with all the variable reference being replaced by the corresponding value in the Hash.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mini_kraken/core/parametrized_term.rb', line 35 def dup_cond(substitutions) duplicate = dup updated_actuals = actuals.map do |e| if e.is_a?(Array) e.map {|item| item.dup_cond(substitutions) } else e.dup_cond(substitutions) end end duplicate.actuals.concat(updated_actuals) duplicate end |
#initialize_copy(orig) ⇒ Object
26 27 28 29 |
# File 'lib/mini_kraken/core/parametrized_term.rb', line 26 def initialize_copy(orig) @specification = orig.specification @actuals = [] end |