Put your code in something.rb and require at the top of your other script (s).
You can also use load instead of require , but require has a nice property that will not contain the file more than once. In addition, using load requires a .rb extension, whereas require does not matter, i.e.
#some_script.rb puts('hello world')
You will almost always use require , but load also an option if you want to use it for any reason.
Ed S. source share