----- Original Message -----
From: "John" <nojgoalbyspam / hotmail.com>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Friday, July 12, 2002 1:58 PM
Subject: Dynamic Methods


> Hi all,
>
> I wonder if anyone has any suggestions on how to create a method that
> matches its name based on a regular expression.  For instance:

[snip]

> I looked at the method_missing feature to implement this.  It gets part of
> the problem solved, but I then don't know what the regular expression for
> the method name is.
>
> Anyone have any ideas or pointers on where I could look?

Not sure *exactly* what you want... the method name gets passed
in, right? As a symbol?

Untested code follows -- doing this from memory.

def method_missing(name,*args)
  if name ~ /^bar.*/
    puts "I'm #{name.to_s}, one of the bar family."
  else
    puts "I'm not a bar at all."
  end
end



Hal Fulton