Closer, but not quite (*). I wasn't think of having a context object to
encapsulate the parameters and passing an instance of the context to the
open-uri method. I was thinking of a new UriOpener class that has methods
similar to the ones in your example, but also has the open method. So all
this progress stuff isn't passed as a parameter at all: it's instance data. 

The old open-uri becomes "return UriOpener.new().open(url)". 

I might use the "context" style you have here if I thought it likely that
I'd want to make it very easy to get Tk progress bars and tty progress bars,
and needed somewhere to put that functionality (in addition to the raw,
low-level "give me a proc"). Even more so if I wanted to implement
equivalent progress functionality for other classes. 

(* I'm sorry if I appear obtuse: I would have "shown you the code" if
weren't away from a proper computer with a proper keyboard and typing this
from a glorified mobile phone!)

 -- elliott

-----Original Message-----
From: T. Onoma <transami / runbox.com>
To: ruby-core / ruby-lang.org <ruby-core / ruby-lang.org>
Sent: Sat Nov 15 23:49:59 2003
Subject: Re: open-uri patch, added progress_proc hook

> No, I definitely wouldn't trade an overly-complex method signature for an
> over-complicated constructor signature. As you say, there's no advantage
to
> that. 
> 
> What I would do is break the complexity up and spread it across a bunch of
> methods on a class. 

you mean something like:

   class OpenURI::ProgessProc     
     def initialize
       @on_empty = false
       @parameters = [ :pos ]
     end
     def progress_proc=(x)
       @progress_proc= x
     end
     def on_empty=(x)
       @on_empty = (x == true)
     end
     def pass_parameters=(*y)
       @pass_parameters = y
     end
   end
 
so that
 
   progress = OpenURI::Progess.new
   progress.progress_proc = proc { |b, t| ... }
   progress.parameters = [ :pos, :total ]
   progress.on_empty = true
   open(url,progress)
 
i don't know if that's all that helpful either. but maybe it is good if it
can be improved.

-t0


*********************************************************************
This e-mail and any attachment is confidential. It may only be read, copied and used by the intended recipient(s). If you are not the intended recipient(s), you may not copy, use, distribute, forward, store or disclose this e-mail or any attachment. If you are not the intended recipient(s) or have otherwise received this e-mail in error, you should destroy it and any attachment and notify the sender by reply e-mail or send a message to sysadmin / bluearc.com
*********************************************************************