Class: TheoryImplementation
- Defined in:
- lib/theory/TheoryImplementation.rb
Overview
Instances of this class are realised theorys. The theory variables have been replaced with values that generate valid ruby code.
Instance Attribute Summary collapse
-
#accessor_values ⇒ Object
readonly
Returns the value of attribute accessor_values.
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Attributes inherited from Theory
#action, #dependents, #example_runtime_method, #results, #theory_id, #theory_instance_id
Instance Method Summary collapse
- #copy ⇒ Object
-
#evaluate_dependent(dependent, runtime_method, test_cases) ⇒ Object
TODO If I remove the code from this method then tc_theory_implementation.rb still passes all the tests!.
-
#initialize(dependents, action, results, mapping, accessor_values = {}) ⇒ TheoryImplementation
constructor
A new instance of TheoryImplementation.
-
#leads_to?(result_description) ⇒ Boolean
Returns true if the result descript matches any of the results for this theory.
-
#meets_dependencies?(runtime_method, test_cases) ⇒ Boolean
Returns true if the implemeted theories pass given the given runtime method and test cases.
Methods inherited from Theory
#all_theory_variables, #components, #describe, #find_component, #has_result_structure?, #highest_theory_variable_id, #highlight, #identify_unchanged, #irrelevant?, load_theory, #map_to, #orphan_action_variables, #rewrite_permutations, #select_result_structure, #uniq_theory_variables, #write
Constructor Details
#initialize(dependents, action, results, mapping, accessor_values = {}) ⇒ TheoryImplementation
Returns a new instance of TheoryImplementation.
12 13 14 15 |
# File 'lib/theory/TheoryImplementation.rb', line 12 def initialize(dependents,action,results,mapping,accessor_values={}) super(dependents,action,results) @mapping, @accessor_values = mapping, accessor_values end |
Instance Attribute Details
#accessor_values ⇒ Object (readonly)
Returns the value of attribute accessor_values.
5 6 7 |
# File 'lib/theory/TheoryImplementation.rb', line 5 def accessor_values @accessor_values end |
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
5 6 7 |
# File 'lib/theory/TheoryImplementation.rb', line 5 def mapping @mapping end |
Instance Method Details
#copy ⇒ Object
17 18 19 20 |
# File 'lib/theory/TheoryImplementation.rb', line 17 def copy #return TheoryImplementation.new(@dependents.copy, @action.copy, @results.copy,@mapping.copy) return Marshal.load(Marshal.dump(self)) end |
#evaluate_dependent(dependent, runtime_method, test_cases) ⇒ Object
TODO If I remove the code from this method then tc_theory_implementation.rb still
passes all the tests!
59 60 61 62 63 64 |
# File 'lib/theory/TheoryImplementation.rb', line 59 def evaluate_dependent(dependent,runtime_method,test_cases) #dependent.statement.push(Parser.run('return true')) last_runtime_method = runtime_method.copy eval dependent.statement.write return false end |
#leads_to?(result_description) ⇒ Boolean
Returns true if the result descript matches any of the results for this theory.
29 30 31 |
# File 'lib/theory/TheoryImplementation.rb', line 29 def leads_to?(result_description) @results.any? {|x| x.statement.write == result_description.write} end |
#meets_dependencies?(runtime_method, test_cases) ⇒ Boolean
Returns true if the implemeted theories pass given the given runtime method and test cases.
TODO There might be a bit of crossover between the TheoryResult validates?
method.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/theory/TheoryImplementation.rb', line 39 def meets_dependencies?(runtime_method,test_cases) self.dependents.collect {|y| y.copy}.each do |x| # TODO I'm not sure there is much benefit in the ParametersContainer class begin unless evaluate_dependent(x,runtime_method.copy,test_cases) return false end rescue NoMethodError => e return false rescue StandardError => e return false end end return true end |