From: RichardOnRails Date: 2011-05-12T09:30:33+09:00 Subject: Re: Scope problem (?) in implementing Design Patterns in Ruby On May 11, 1:52 pm, David Jacobs wrote: > [Note:  parts of this message were removed to make it a legal post.] > > I think the second link points to the wrong pastie. > > I can see a couple of problems with the code, first of which is that you are > setting up Expression.new to require an argument but not passing it an > argument when you call All_basic.new, etc. > > More than design patterns (which I think are a little much here), I would > suggest looking into Ruby's higher order functions like reduce and map. They > make your code a lot simpler. This is an alternate implementation I did. Let > me know what you think: > > http://www.pastie.org/1889838 > > On Wed, May 11, 2011 at 1:20 PM, RichardOnRails < > > > > > > > > RichardDummyMailbox58...@uscomputergurus.com> wrote: > > Hi, > > > I'm hoping that employing "Design Patterns in Ruby" will lead to less > > coding errors and more easily maintained code.  I'm stuck with the Not > > pattern in the File Finding pattern in Chapter 15. > > > I've posted my code and output inhttp://www.pastie.org/1889586and > >http://www.pastie.org/188968, respectively.  Any idea about the cause > > of the reported syntax error? > > > Thanks in Advance, > > Richard > I think the second link points to the wrong pastie. It sure does. I apologize for that error. My results are at http://www.pastie.org/1889681 > This is an alternate implementation I did. Let > me know what you think: > > http://www.pastie.org/1889838 I downloaded your example, removed a few spurious "end" statement and added a "p" to get the Regexp class name. It ran perfectly as far as I can see, but I'd have to format the output to confirm that. The code looks great, but I'll await a real comparison until I get the book's code working > I can see a couple of problems with the code, first of which is that you are > setting up Expression.new to require an argument but not passing it an > argument when you call All_basic.new, etc. Thanks for this possible solution. I'll try to correct that after I look at the other posts I've been lucky enough to get. Best wishes, Richard