© Carleton DiLeo 2019Carleton DiLeoClean Rubyhttps://doi.org/10.1007/978-1-4842-5546-9_5
Boulder, CO, USA
In this chapter, we cover several techniques you can use to make high-quality classes.
When instantiating a class in Ruby, the new class method calls the initialize instance method. Any parameters passed to the new method will be passed to the initialize method. The initialize method is a setup method for a class. It’s called before any other method defined in the class. If we have steps to perform before using the class, we place them in the initialize method. Let’s look at techniques we can use to improve our initialize methods.
The initialize method should be simple, which means ...