From: James Coglan Date: 2009-04-17T21:06:01+09:00 Subject: Re: simple module method call question --001636c5b6daa72d4e0467bf0045 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > This always fails. I've tried every trick I can think of, but always I get > this: > > ../lib/setnet/SN.rb:579:in `proc_command': undefined method `orph_chk' for > Utils:Module (NoMethodError) > from ../lib/setnet/SN.rb:229:in `eval' > from ../lib/setnet/SN.rb:579:in `proc_command' > from ../lib/setnet/SN.rb:229:in `user_interface' > from ../lib/setnet/SN.rb:146:in `manage' > from ../lib/setnet/SN.rb:68:in `startup' > from ./setnet:28 > > Can someone suggest why I'm not able to get to this method? > > Here's the relevant Module, in abbreviated form: > > module Utils > > MENU = [ > ["orph_chk", "searches nodes and links for references which cannot be > resolved, and reports them"], > ["tree_count","starting with node 'root', locates descendants of each > node, displaying count at each level"], > ["showtree","starting with node 'root', locates and displays descendants > of each node"], > ["tree_orphans","locates links which cannot be traced to the root node, > and displays them"] > ] > > def orph_chk > puts 'orph_chk' > end > > end You've defined an instance method, not a module method. The method as you define it will appear in classes that use 'include Utils'. To get a module method, define it on self: module Utils MENU = [ ... ] def self.orph_chk # ... end end -- James Coglan http://github.com/jcoglan --001636c5b6daa72d4e0467bf0045--