Henry Maddocks wrote in post #1072063:
> On 12/08/2012, at 12:24 AM, Ja Tse <lists / ruby-forum.com> wrote:
>
>> Not sure how to put it just want to know, wat's the advantage of
>> creating an object through a proxy method in this case #open vs just
>> creating an object with the constructor Foo.new ?
>>
>
>
> You have partially implemented two patterns...
> Factory Method; A class method that returns an instance of the class
> based on the inputs. Your method always returns the same objectso there
> is no point creating another method to do this. Just use #new.
>
> Around Method; When accessing a resource that requires setup and tear
> down, eg. File open / file close, you can write a method that initialzes
> the resource, yields the resource to a block then clens up the resource
> when the block returns. Your method doesn't do this either but it's
> probably what you were thinking of as it is a very common Ruby pattern.
>
> Henry

Thanks Henry and everyone,

I knew my code was not perfect it was just a starting point and I wanted
someone to elaborate more on the subject.  Thanks everyone I have a
better understanding now.

-- 
Posted via http://www.ruby-forum.com/.