From: Mlle Date: 2011-03-07T06:50:29+09:00 Subject: Re: ruby script On Mar 6, 4:43 pm, Brian Candler wrote: > Mlle wrote in post #985808: > > > I wrote a ruby script but I'd like to define a method within it and > > call the method from the main method.  How do I do that?  Do I have to > > define the whole file as a module or something? > > Nope (although using modules can make your code easier to reuse and/or > combine with other code) > > Simple example which I think achieves what you want: > > ---- a.rb ---- > def say_hello >   puts "Hello, world!" > end > > ---- b.rb ---- > require 'a' > say_hello > > ---- command line ---- > ruby b.rb > > -- > Posted viahttp://www.ruby-forum.com/. I realized I was having issues because I defined the method I wanted to use after the script...obviously it should be defined before. Then it runs just fine without having to be a module.