I have a module as following,
main.rb:
module Main
include Dad::Mam
end
and
in dad.rb:
module Dad
module Mam
puts "Mam is saying you are very lazy..."
end
end
How can I name this file? dad.rb is right?
but when running
$ ruby main.rb
I am getting an Error like,
main.rb:2:in
<module:Main>': uninitialized constant Main::Dad‘
(NameError) from main.rb:1:in
I need to show the sentance inside the puts under Mam module while running ruby main.rb,
I am confused about using ruby’s modules, please anyone help me and guide me..
In this case, since you’re just writing a simple script, use
#require_relativeFor an actual app or library, you would want to manage the load path (a global variable holding an array that tells ruby where to look for files) and then use a normal
require