From: matt@... (matt neuburg) Date: 2008-05-04T00:35:16+09:00 Subject: Re: "require" with many files I�aki Baz Castillo wrote: > Hi, is there any preferred way to load/require all the fiels in a directory? > For example, my main file does: > > require "header.rb" > > and file "header.rb" must load all the related files contained in > "headers/" directory. I do the following in "header.rb": > > headers_path = File.dirname(__FILE__) + '/headers' > Dir.chdir(headers_path) > Dir["*.rb"].each do |file| > require "#{headers_path}/#{file}" > end > > Is it enought ok or can it receive some Ruby's magic? If you say $: << theDirectory then you can just require the files by name, I believe... m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Leopard - http://www.takecontrolbooks.com/leopard-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com