Class: DeclarationStatementEvaluation
- Defined in:
- lib/util/DeclarationStatementEvaluation.rb
Instance Method Summary collapse
-
#evaluate(written_statement, runtime_methods = []) ⇒ Object
NOTE It might improve performance if this was a singleton.
Instance Method Details
#evaluate(written_statement, runtime_methods = []) ⇒ Object
NOTE It might improve performance if this was a singleton
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/util/DeclarationStatementEvaluation.rb', line 4 def evaluate(written_statement,runtime_methods=[]) # Create file to include the test method file = Tempfile.new("runtime_declaration_statement_evaluation.rb") # Include the sytax for the statement in the file file << 'class RuntimeDeclarationStatementEvaluation'+"\n" file << "\t"+'def check'+"\n" file << written_statement file << "\t"+'end'+"\n" # Add and associated runtime methods runtime_methods.each do |x| file << x.write end file << 'end' file.close # Load the newly created class and check the statement load filepath return RuntimeDeclarationStatementEvaluation.new.check ensure file.close file.unlink end |