On May 11, 2:37=A0pm, David Jacobs <develo... / wit.io> wrote:
> [Note: =A0parts of this message were removed to make it a legal post.]
>
> One more suggestion: if you're going to build a hierarchy, might as well
> work the parent as much as possible. My final implementation would probab=
ly
> look something like this:
>
> http://www.pastie.org/1889969
>
>
>
>
>
>
>
> On Wed, May 11, 2011 at 1:51 PM, David Jacobs <develo... / wit.io> wrote:
> > 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 yo=
u
> > 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 wou=
ld
> > 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. =A0I'm stuck with the N=
ot
> >> 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. =A0Any idea about the cause
> >> of the reported syntax error?
>
> >> Thanks in Advance,
> >> Richard

Hi David,

Assuming I'm responding to the correct you version works perfectly, as
evidenced by results below gotten after I decorated your code with
puts versions.

The Design Patterns author,  Russ Olson, is aims to support a neat DSL
to support file search with arbitrary logical combinations of the
fundamental search elements ... which is my adopted goal.  So I've got
to master his approach to implementing this search language before I
can really weigh approaches.

7stud has responded with the key thing I saw but couldn't figure out
how to address the problem, so I've got to follow up on that now.

Thanks for very detailed responses in intrinsic Ruby education.

Best wishes,
Richard

=3D=3D=3D=3D=3D=3D=3D=3D Output =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>ruby DavesTempFilesDirs_2.rb

files.select &all
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
AlternativeFileSearch.rb
DavesTempFilesDirs_1.rb
DavesTempFilesDirs_2.rb
FindFilesDirs-01.rb
FindFilesDirs-02.rb
FindFilesDirs.rb
TempFindFilesDirs.rb
TestDoc@.txt
TestFolder
TestFolder/TestDoc.txt

files.select &filename(/-01/))
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
FindFilesDirs-01.rb

files.select &writable
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
AlternativeFileSearch.rb
DavesTempFilesDirs_1.rb
DavesTempFilesDirs_2.rb
FindFilesDirs-01.rb
FindFilesDirs-02.rb
FindFilesDirs.rb
TempFindFilesDirs.rb
TestFolder/TestDoc.txt

files.select &_not(writable)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
TestDoc@.txt
TestFolder
>Exit code: 0