What's the benefit of putting all my methods inside a Module?
module Math
def Math.print_message
puts "Testing 123 ..."
end
end
If I just write "print_message" in the file and then require the file from within another file, then I can call "print_message" as well.
What's the advantage of having it within this Module-end construct?
In many ways, modules act a lot like classes, although you can't actually instantiate them. There are quite a number of reasons to put code, classes, and other objects inside modules. These include:
There are likely other things that I haven't thought about in this quick, off-the-cuff answer. However, modules are essential building blocks for gems and larger Ruby applications, and understanding them is worth doing, especially if you're planning to grow beyond basic scripting with Ruby.