From: Henon Date: 2005-04-30T06:29:28+09:00 Subject: Re: method_missing question Joe Van Dyk wrote: > Currently, I have a class that has a bunch of methods (that a GUI does > a callback on) that are like > > def menu_zoom_100_activate > @display.zoom(100) > end > > def menu_zoom_250_activate > @display.zoom(250) > end > > def menu_zoom_500_activate > @display.zoom(500) > end > > Could I use #method_missing to make this better? > > > you could do that like this: def method_missing(methodname, *args) if methodname=~/menu_zoom(\d+)_activate/ @display.zoom($1.to_i) else super end end