I want to use the object created in main script globally.
for ex I have different module in different file and class in different ruby file
FileNameModA.rb
module A
# ........
# some code here
# ........
end
FileNameModB.rb
module B
# ........
# some code here
# ........
objReport.addReport() # getting an error "ruby uninitialized local variable or object: Main"
end
FileNameClass_Report.rb
class Report
def addreport()
end
end
MainScript.rb
require "FileNameModA"
require "FileNameModB"
require "FileNameClass_Report"
include ModuleA
include ModuleB
objReport = Report.New
objReport.addReport() # Works fine here
Could you please let me know how to create and use object in different file/module of Ruby?
require_relative 'filename'in 1.9+.objReport.addReport()to work in FileNameModB.rb?