CONSTRUCTORS – NEW AND INITIALIZE
For now, let’s take a look at another example of a user-defined class. Load up 7treasure.rb. This is an adventure game in the making. It contains two classes, Thing and Treasure. The Thing class is very similar to the Cat and Dog classes from the last program – apart from the fact that it doesn’t woof or miaow, that is. The Treasure class hasn’t got get_name and set_name methods. Instead, it contains a method named initialize which takes two arguments whose values are assigned to the @name and @description variables: