In Ruby we can create module functions for named methods that may be called with the module as a receiver, and these functions also become available as instance methods to classes that mix in the module. There are multiple techniques to achieve this in Ruby, but the simplest and best known are Module#module_function and extend self.
Ruby supports magic comments (interpreter instructions) at the top of the source file, mostly known for setting a source files' Encoding. But there is more you can do.
With uniq method you can remove duplicates from an array, however using the bitwise | operator we can avoid adding duplicate items in the first place.
The built-in class File provides the facilities for manipulating files in Ruby. Let us explore the basic file operations, including opening, reading, writing along with querying file objects to get information about the file itself.
There comes a time when you need to load data from multiple sources to futher processing in your application. Let's see how we can do this with ease in this post and load data from multiple files in Ruby using Hash.