On 2007-06-16 03:07:57 -0500, "Erwin Abbott" <erwin.abbott / gmail.com> said:

> On 6/16/07, Banzai <noemail / yahoo.com> wrote:
>> ...
>> d = Door.new("/path/to/door", "func")
>> Is it more convenient to say:
>>         d = Door.new(:path => "/path/to/door", :proc => "func")
> 
> From my experience the most Ruby-like way of doing this would be
>    d = Door.new("/path/to/door") { |arg| arg ** 2 }
> 
> You can implement it like this
> 
>   class Door
>     def initialize(path, &block)
>       # var named block is now a Proc object
>       @block = block
>     end
>   end
> 
> Regards,
> - Erwin

Thank you for your input, Erwin.

Remember that my extension is written in C, so the implementation would 
be a bit more involved.  :-)

I do like the idea...  But, I think Door should be a subclass of File, 
and File doesn't like a code block for an argument, and I'll get this 
warning:

warning: Door::new() does not take block; use Door::open() instead

This warning comes from rb_io_s_new() in io.c, so I don't think I can 
suppress it if I say:

	rb_define_class("Door", rb_cFile);

-- 
H. Asari