From: Alex Young Date: 2007-07-31T05:51:53+09:00 Subject: Re: Passing variables to a required file 12 34 wrote: > I want to pass about 10 variables to a "require"d file. My understanding > is that I need to use global variables. Is this correct? > > I'm reluctant to change all the variables to global for fear of messing > up the methods in the script. I can of course define new global > variables equal to the local variable. Seems inelegant. > > I guess my best option is to rework the require'd file as a method, but > my script is getting long and keeping the file separate makes sense, > particularly since it is creating the GUI, so is different from the > script function if I understand the MVC philosophy. > > Is there a better way? FWIW I'm "require'ing a modified example.rb file > that is included in the Pashua app for creating a simple GUI for OS X. > Change your code. It'll be easier to do it now than to unpick everything later. What you want (probably) is to wrap your code in the require'd file into a class that you can instantiate with the relevant parameters in your main script. > Thanks for info > > PS The example file as a > > Config = < > > EOS > > I can't find EOS in Ruby on Rails or PickAxe, so maybe I'm missing > something in how it's used. It's a heredoc marker. It's just another way of creating a multiline string. The critical bit is the "<