June 2017
Beginner
330 pages
7h 30m
English
Let's say we have a method that does not start with author_. In that case, we tell Ruby that we don't have any code for such a method. In other words, we want Ruby to generate methods only for those values that start with author_ and not for other methods.
To check whether this code works, let's instantiate Author. We will create a new variable called author and set attributes for this object.
Let's test it out. Before that, let's print out our author's first name to know whether the program is working fine. We add this piece of code to establish a base case:
p author.first_name
The output will be as follows:
"Cal"
That's right!
Now, let's see what happens if we change it to:
p author.author_genre
The output ...
Read now
Unlock full access