From: Gregory Seidman Date: 2008-03-03T23:36:05+09:00 Subject: Re: YAML On Mon, Mar 03, 2008 at 10:49:54PM +0900, aidy wrote: > Hi Greg, > On 28 Feb, 20:40, Gregory Seidman > wrote: > > On Fri, Feb 29, 2008 at 01:09:55AM +0900, aidy wrote: > > There are two things I do not undersand > > 1) why you have added a method to this class: > > def SmokeTest.create_from_yaml_file(filename) > > 2. And how can you get away with instantiating here. > > obj = new(data['test'], data['url']) Well, it's sort of a constructor built on top of the standard constructor (new). It certainly belongs to the class, since it is building an object of that class, and because it is a method of that class object, it can call new without fully qualifying it (i.e. SmokeTest.new). Remember that there is nothing terribly special about the new method. I believe it does nothing more than call alloc (to get an uninitialized object of the class) then call initialize on that object. (I'm sure I will be corrected if there is more to it than that.) Likewise, there is nothing special about the initialize function. By convention (and default implementation), it is called by the class new method, but it's just a method like any other. All I did was write a new constructor for your class, wrapping the default constructor. > Cheers > Aidy --Greg