Make your ruby classes Comparable and Enumerable
Something very cool in ruby are mixins. As the word says mixin is a technique to mixed a module into a class using the statement “include”. While including a module is a very large topic I focused on the opportunity to include module defined in the Ruby standard library into your class to take advantages of the methods and abilities that these modules provide. The Comparable module in ruby define methods like < <= == > >= between? . What if I want to achieve is making my class instances comparable so that I can ask to ruby if class_a > class_b. Here an example: <div></div> The Person class include the module Comparable and implements one single method (<=>). This methods is used by the Comparable module to perform the logic of any of the operator that the module provide.In the example I say to the Person class to compare instances through the @name attribute. But we even gain more functionalities. Once that our classes are able to be compared they are also able to be sorted if placed inside an array. Amazing!!!