Join Kevin Skoglund for an in-depth discussion in this video Documentation, part of Ruby Essential Training.
Before we dive into learning Ruby, there is one last thing that I wanted to introduce in this Getting Started section, which is the documentation on Ruby. The best place to get the documentation is from the Ruby Documentation website, and that's www.ruby-doc.org/core/. Now, if you were just to go to the ruby-doc website, you will be able to find the core API for your version of Ruby directly from there, but core will take you straight there. So here I am on the ruby-doc website. The link that I was talking about is the 1.8.6 core. You will see that that's going to take us to the same place that we would have gone otherwise.
So that's just going to be here, ruby-doc.org/core. This is going to be all of the different classes and methods and files that are available to us in Ruby, and we can do a search to find the things we want. This will all make a lot more sense to you as we start learning Ruby, but I want you to know where it is now. So for example, if I pick the class string, you will see that it takes me to a page about the strings and then I can pick a method like upcase here, from its methods, and we can see what it does, and it reports back that string upcase returns a copy of the string with all lowercase letters replaced with their uppercase counterparts, and then it gives me an example.
So that's going to be the kind of information we can get to find out how to use these different methods inside the different classes of Ruby. Now, that same documentation is also available to you from the command line. So if we go into our terminal, we can type ri, which stands for Ruby Information, and then we can type in something like upcase. It will come back and it will report to us about upcase, and it will say ah, actually I have several different things called upcase, which one do you mean? You will notice here that it has String, then the pound sign, and upcase, and that's the format that it wants.
When you see END, you will want to hit the Q to get back out of it. So let's try it again with String#upcase, and you will see that it comes back and it says the exact same information that we had on the website. The difference is this is stored locally on our computer. So if, for example, we are on an airplane and we are trying to remember how something works, we can just pull it up off of our laptop directly without having to have an Internet connection. So I will hit Q one last time. Let's take a look at another one, which is going to be ri Object#inspect.
Now, I just wanted to introduce this idea of inspect to you. Remember, almost everything is going to be an object in Ruby, so this is going to apply to a lot of different things, and we can use inspect. It's going to return a string containing a human readable representation of the object. So just keep that in mind. We will be using inspect from time to time to just see what an object looks like in its human readable form. Now, a lot of times it's hard to represent a complex data structure as something human readable, but it will do its best. But I just wanted to introduce that other bit of Ruby before we go on. But the main thing to remember is that for the documentation, you can go to the ruby-doc website, or you can type in ri for Ruby Information to get that same information directly off of your computer.
It's stored with your Ruby installation. Now that we have got everything installed and we are oriented a little bit to the way that the Ruby programming language is going to work, we are ready to actually start learning the syntax of the language. We will do that in the next chapter.
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- 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.