From: Tom Sawyer Date: 2002-07-13T04:56:21+09:00 Subject: Re: Dynamic Methods somthing like: def method_missing(name, *args) meths = instance_methods + private_instance_methods + protected_instance_methods re = Regexp.new("(#{name}.*)[;]") md = re.match(meths.join(';')) send(md[1], *args) if md end essentially it looks at all the methods available and finds a match then uses send to call it. this is not tested, but should work along these lines. could also be made a little more concise. ~transami On Fri, 2002-07-12 at 12:58, John wrote: > 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: > > class Foo > def /bar*/ > puts "Wow!" > end > end > > Then I could do something like: > > foo = Foo.new > foo.barchart > foo.barstweward > > The regexp method name throws the interpreter off of course. > > 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? > > TIA, John. > > > -- ~transami __("< berk! berk! \__/ ^^