From: ara.t.howard@... Date: 2006-06-13T12:00:01+09:00 Subject: Re: How to invoke a run method??? On Tue, 13 Jun 2006, Eric Armstrong wrote: > This is pretty ridiculous, but I have tried > virtually every combination of class and module > definitions that I can think of, all without > success: > > I started with an old Post by Ara Howard: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193039 > > module Foo > class Main > ... > end > end > Foo::Main.run(ARGV, ENV) if __FILE__ == $0 Foo::Main.new.run(ARGV, ENV) if __FILE__ == $0 ^^^ ^^^ ^^^ > Then I found the ERB program at > http://stuff.mit.edu/afs/sipb/project/ruby-lang/bin/erb > > That one reverses class & module: > > class ERB > module Main > def run def self.run > puts "Running" > end > end > end > Foo::Main.run if __FILE__ == $0 > What the heck is wrong with this picture? > (thanks in advance) in both situations you are reversing the notion of class/module and instance methods. in the first case you call a class method when it should be an instance method, in the second you define an instance methods and then try to call a class method. module M def self.foo 'this is a class/module method' end def bar 'this is an instance method' end end we can do M.foo class C include M end C.new.bar alternatively we can have class C def self.foo 'this is a class/module method' end def bar 'this is an instance method' end end and do C.foo C.new.bar make sense? -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama