Chapter 11 - Documentation
Exercise 1: Looking up docs for a Ruby core class
Using the Ruby core class Time
, write a program to print the current date in the format below.
We did a Web search for “ruby Time”, and found the following page: Ruby Time
class.
Here are the methods we used:
now
class methodwday
instance methodmonth
instance methodday
instance methodyear
instance method
And here’s the resulting code:
Sample output might look like this: