Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Let's do a quick review of everything we've learned in this course.
Things to Try
-
The
rand
method generates a random number within a given range.rand(4)
returns a random number between0
and3
.rand(6)
returns a number between0
and5
. Write a program that simulates rolling a die, and tells the user's fortune based on the resulting number. -
downcase
,upcase
, andreverse
are just a few of the interesting methods available on strings. Write a program that lets the user type a string, and then asks them if they'd like to see it in lower case, upper case, reversed, etc. Call the appropriate method on the string, and print the result.
Installing Ruby on Your Computer
Windows
- Download and run Ruby Installer from rubyinstaller.org. (For convenience, we linked directly to the version you need. The rubyinstaller.org site hosts its files on bintray.com.)
- Allow the download to finish, then go to your Downloads folder, and open the "rubyinstaller" program. An installation wizard will open. Check "Add Ruby executables to your PATH", then click Install. Wait while the installer runs, and click Finish when done.
- To access Ruby, go to the Windows menu, click All Programs, scroll down to Ruby, and click "Start Command Prompt with Ruby". A command prompt terminal will open. If you type
ruby -v
and press Enter, you should see the Ruby version number that you installed.
Mac
We're going to install rvm
, the Ruby Version Manager. rvm
will download, compile, and install new Ruby versions for us.
Copy and paste these two commands into your terminal:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
(Yes, that is a backslash before the "curl" command. It's there to avoid potential version conflicts.)
rvm
is now installed, but it won't be available until you open a new terminal window. So go ahead and open a new window from the menu. Then, try running the "rvm" command all by itself. If it outputs usage information, you'll know it's working.
Now that rvm
is installed, we can have it install a new Ruby version for us. Run this command from your terminal:
rvm install 2.3.1
When it returns to the system prompt, Ruby will be installed. But it may not be available in your terminal yet. To tell rvm
to use the Ruby version you just installed, and to use this version by default in the future, run this command in your terminal:
rvm use 2.3.1 --default
Linux
We chose Ubuntu as the distribution to demonstrate for Linux, but you should be able to adapt these directions for other distros.
First, open a terminal. If you haven't done that before, you can click the button in the upper-left to search your computer, and type "terminal". Click the "Terminal" application in the list of results. Once that's done, you'll be ready to follow along for the rest of these directions.
We need to install rvm, the Ruby Version Manager. rvm will download, compile, and install new Ruby versions for us.
But to install rvm, we first need the "curl" program. We'll install that via a package manager. In your terminal, run this command:
sudo apt-get install curl
You'll need to provide your system password. When the installation is complete, you'll be returned to your system prompt.
Now we're ready to install rvm. Copy and paste these two commands into your terminal:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
(Yes, that is a backslash before the "curl" command. It's there to avoid potential version conflicts.)
rvm is now installed, but it won't be available until you open a new terminal window. So go ahead and open a new window from the menu. Then, try running the "rvm" command all by itself. If it outputs usage information, you'll know it's working.
Now that rvm is installed, we can have it install a new Ruby version for us. From your terminal, run:
rvm install 2.3.1
rvm may need to install some packages that Ruby depends on. If it asks, type your system password and press Enter to continue.
When it returns to the system prompt, Ruby will be installed. But it's not available in your terminal yet. If you type ruby -v
to look at your ruby version, you'll probably either get a message saying Ruby is NOT installed, or you'll get an older version of Ruby. To tell rvm to use the Ruby version you just installed, and to use that version by default in the future, run:
rvm use 2.3.1 --default
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up