Join Kevin Skoglund for an in-depth discussion in this video Solution: Birth date analysis, part of Ruby: Classes and Modules.
(mystery music)…- [Instructor] Hopefully, you were able to come up…with a solution to the birthdate analysis challenge.…In this movie, I'm going to show you the solution…I came up with.…So I've got a new project here called…birthdate underscore analysis,…and it's got one file in it, init.rb.…Doesn't have any class definitions.…Just a simple script.…It's got my shebang line at the top…to follow best practices.…And notice that I'm using require…to require that date library.…So, now I have date and date time available to me…as classes to work with.…
I also just find a variable here called days.…And it just has the days,…Sunday, Monday, Tuesday, Wednesday,…all the way through Saturday as a simple array.…We'll come back to that in a minute.…Then it's going to output some introductory text here…and have what year were you born presented to the user.…The user will then provide some input.…We'll use gets and chomp with that.…So it'll get the input…and chop off the ending line return.…And I'll assign that equal to year.…I'll do the same thing for month and for date.…
- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.