Should methods be inside classes? in Ruby
This &quot;global function&quot; style works for small scripts but isn't reusable.
A more practical problem with it is if you want to have state that is shared between functions, you don't have anywhere to store it (well, you could use global variables ($var), but that's prone to conflicts).
For a more encapsulated design, create a class that does the work and move the methods into the class. See for example definition and usage.