Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Comprehensive Ruby Programming

You're reading from   Comprehensive Ruby Programming From beginner to confident programmer

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787280649
Length 330 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jordan Hudgens Jordan Hudgens
Author Profile Icon Jordan Hudgens
Jordan Hudgens
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Introduction to the Ruby Programming Language FREE CHAPTER 2. Ruby Variables 3. Ruby Strings 4. Working with Numbers in Ruby 5. Ruby Methods 6. Ruby Iterators and Loops 7. Ruby Collections 8. Ruby Conditionals 9. Object-Oriented Programming in Ruby 10. Working with the Filesystem in Ruby 11. Error Handling in Ruby 12. Regular Expressions in Ruby 13. Searching with grep in Ruby 14. Ruby Gems 15. Ruby Metaprogramming 16. Ruby Web Frameworks 17. Working with APIs in Ruby 18. Ruby Algorithms 19. Machine Learning

Installing Ruby on a computer

Before we can start programming, you'll need to get Ruby installed on your system. I'm going to walk you through how you can install it on your computer regardless of your operating system, and I'll also give you alternate options if you don't want to install Ruby locally (however I highly recommend installing it).

Ruby language dashboard

Let's start by going to http://ruby-lang.org:

When you click on the Download Ruby button, it will take you to the following page:

This page gives you information on how to install Ruby on your system.

If you are using the Windows operating system, follow these steps:

  1. Go to rubyinstaller.org:
  1. From this list, you can pick the stable version you want, I recommend that you go with the latest stable version. When you click on any of these links, the installer will run and you will be ready to go.

If you're using macOS, Ruby is already installed on your system. To check this follow these steps:

  1. I created a file called do_I_have_ruby.rb, which has only one line of code in it:
     puts "Yes, you have Ruby!"
  1. Next, go to your Terminal (make sure that you're in the same directory as your Ruby file) and run the file with the following command:
      ruby do_I_have_ruby.rb

This should display your string, if Ruby is properly installed:

If you don't feel comfortable creating and running a Ruby file like this, you can simply type irb into a Terminal window and if it opens up it means that you have Ruby. You can also type ruby -v to have the system show you what version of Ruby is installed.

One thing that you can do if you are using the Mac or Linux operating systems is to use the Ruby Version Manager (RVM). This gives you the flexibility to use different Ruby versions for different projects.

To install RVM, go to http://rvm.io, and here you will find the Terminal commands that you can simply copy and paste in your Terminal:

Once you've installed RVM, type rvm list and this should list out all the Ruby versions on your system. If you want to change versions you can call the use command. For example, type in your Terminal to switch to Ruby version 2.4.0:

rvm 2.4.0

If you don't want to install Ruby on your local system, but still want to learn how to build Ruby programs, you can go to http://repl.it/languages. This should give you the list of languages available in the repl.it dashboard. When you click on Ruby, it will take you to a Terminal that will render all your Ruby code.

I tend to use this site if I have to quickly debug an algorithm or a confusing script. It's a great tool because you're able to get a side-by-side perspective on your code with its output:

So that's how you install Ruby! Now with that installed, you're ready to start learning how to build Ruby programs!

You have been reading a chapter from
Comprehensive Ruby Programming
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781787280649
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image