From: Ralf Mueller Date: 2012-04-13T16:24:59+09:00 Subject: Re: How to read a file and execute its code which relates to the current class On 04/13/2012 07:44 AM, dongcan z. wrote: > I have a problem.I want to read codes from a file.And the codes in the > file use some methods which I defined in the main process. So I don't > know how to deal with it. Please help me. > Thank you! > > > > Here is an example: > class Job > def job_handle > ....... > end > def job_load > File.open("the file") > end > def job_exception > end > end > In file "the file",the codes contain the job_exception and job_load > methods. > if "the file" contains ruby code, you could use "load" or "require". Search for "Including Other Files" in http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html ralf