RockPaperScissors

LizardSpock

Ruby Include (Require) Local Files

| Comments

Also a gist on github. This is an example of how you can require files in a relative path to the script. As Ruby scripts execute from which ever path they were called.

#!/usr/bin/env ruby

#A way of including local functions in sub folders 
path = File.expand_path $0
path = File.dirname(path)

require "#{path}/SubDir/function_1.rb"
require "#{path}/SubDir/function_2.rb"
require "#{path}/SubDir/function_3.rb"

#or change working dir of script
Dir.chdir(path) 

Comments