From: Eric Armstrong Date: 2006-06-14T04:24:31+09:00 Subject: Re: How to invoke a run method??? Thanks to you, too, Daniel. BTW: I notice you use $PROGRAM_NAME, instead of $0. I take that is a recently added variable? My five Ruby books don't seem to mention it. --signed, Hopelessly addicted to paper Daniel Harple wrote: > On Jun 13, 2006, at 4:37 AM, Eric Armstrong wrote: > >> I construed that post to mean that this work: >> >> module Foo >> class Main >> def run >> puts "Running" >> end >> end >> end >> Foo::Main.run() if __FILE__ == $0 >> >> But the result was: >> undefined method `run' for Foo::Main:Class > > > #run is an instance method. You could make it a class method: > > module Foo > class Main > def self.run > puts "Running" > end > end > end > Foo::Main.run if __FILE__ == $PROGRAM_NAME > > Or instigate an object of class Foo::Main: > Foo::Main.new.run if __FILE__ == $PROGRAM_NAME > > -- Daniel > >