From: 12 34 Date: 2007-07-31T08:14:30+09:00 Subject: Re: Passing variables to a required file Alex Young wrote: > 12 34 wrote: >>> main script. >>> >> >> OK. For now that's the best solution for me, but later I will look at >> putting in a separate file. > Well, the class definition can still be in the external file - that's > actually what I meant. You can do something like this: > > main.rb: > > require 'ui_code' > > UICode.new(all, your, parameters).run > > ui_code.rb: > > class UICode > def initialize(use, meaningful, parameter, names) > @use = use > @meaningful = meaningful > # etc... > end > > def run > #your current code goes here, referring to instance variables > rather > # than globals > end > end > > That's a fairly typical arrangement, in fact. Thank you for clarifying this. Since it's a one shot thing I've been using defs and not classes. But maybe that makes a difference. I need to reread my books to get clearer on this. > >> didn't quite look like Ruby, missing quotes and things. >> >> So EOS presumably means something like End of String and is commonly >> used but has no special meaning to Ruby. Confusing also to me that the >> word in front of <> name or word with a special meaning. > Nope, it's just a variable name. Except that here it's a little weird - > because it's capitalised, it's a constant. Not sure if that's relevant, > but don't worry about the specific name "Config" being anything special. Turns out to matter a lot. Broken with EOS, works with eos. Although did worked when in a separate file. I had moved it into my main script. I came back to the thread to repost about an error I was getting at the <