Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Comprehensive Ruby Programming
Comprehensive Ruby Programming

Comprehensive Ruby Programming: From beginner to confident programmer

By Jordan Hudgens
$35.99 $24.99
Book Jun 2017 330 pages 1st Edition
eBook
$35.99 $24.99
Print
$43.99
Subscription
$15.99 Monthly
eBook
$35.99 $24.99
Print
$43.99
Subscription
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 30, 2017
Length 330 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781787280649
Category :
Table of content icon View table of contents Preview book icon Preview Book

Comprehensive Ruby Programming

Introduction to the Ruby Programming Language

Welcome to the Comprehensive Ruby Programming book! I'm excited to go through all the materials and walk you through this great programming language.

I've been a programmer for more than a decade, and I started Ruby about five years ago. Since then, I absolutely fell in love with Ruby for a wide array of reasons. As you learn the language you'll discover that you spend less time worrying about the syntax and more time coding, which adds to the fun. By the time you're finished with this course I hope you'll love this language as much as I do!

In this chapter, we'll take a high level view of the Ruby programming language, learn how to install it on your system, and get it up and running so you can start building Ruby programs. By the end of this chapter, you will have learnt the following:

  • Describe the high level concepts of the Ruby programming language
  • Construct the configuration to run Ruby programs
  • Define how to work with multiple Ruby versions

What is Ruby?

Ruby is an open source programming language, which means that it's free to use, and it was developed by a large community of developers.

So what can you do with Ruby? By leveraging the Ruby programming language you can build many different types of applications. If you're interested in building dynamic web applications you will most likely want to learn the Ruby on Rails web framework. Since Rails is built on top of Ruby, it's beneficial to understand how to program in Ruby before you can use Rails properly.

Popular sites that use Ruby

So what sites use Ruby?

  • hulu.com: A popular destination to watch TV shows and movies online
  • twitch.tv: A video game-viewing site that was acquired by Amazon
  • lumosity.com: A popular learning platform
  • weheartit.com: A great entertainment site
  • bloomberg.com: An application that processes news and financial data to give financial insights to users
  • github.com: One of the most well-known Git repositories, GitHub enables developers from all over the world to host their code and collaborate with others

Now that you know the kind of applications that we can build with Ruby, let's get started!

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!

Installing different Ruby versions with RVM

If you're interested in using RVM to manage multiple versions of Ruby on your system, I want to give some more detailed instructions on how you can accomplish this:

  1. Start out by going to your Terminal and typing the following command:
      rvm list

If you have RVM installed, this will bring up all of the versions of Ruby that you have access to on your computer.

  1. If there is a version of Ruby that you want and that you don't already have on your system, simply type this in to the Terminal:
      rvm install 2.3.0  

Running this command will install the 2.3.0 version of Ruby for you:

You can do this for any versions of Ruby that are available via RVM. This makes it easy to ensure you're always using the most up-to-date version of the language. Using RVM is also helpful if you have different projects that utilize various versions of the language. For example, I have some legacy Ruby projects that use Ruby version 1.9.3, while all of my new projects use Ruby 2.3.0 (at the time of writing this guide).

By leveraging RVM, I can quickly switch between different versions of Ruby with a simple Terminal command. Alternatively, if you're not a fan of RVM, you can also use rbenv, which is a similar service.

Summary

In this chapter, we discussed what Ruby is and the popular applications that utilize the Ruby programming language. We also looked at the step-by-step approach of installing Ruby on your computer. With Ruby installed, we also acquired the tools needed to run Ruby programs and go through this book. We later extended our system's functionality and walked through how to install multiple versions of Ruby on our computers, which can be a helpful tool when working with multiple applications that require varying versions of the language.

In the next chapter, we will dive into how to work with variables in Ruby, which will give us the ability to store data and work with it in Ruby programs.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • • Provides the core skills required to become a Ruby programmer
  • • Covers how to use the most popular Ruby Gem libraries
  • • Includes details on regular expressions

Description

Ruby is a powerful, general-purpose programming language that can be applied to any task. Whether you are an experienced developer who wants to learn a new language or you are new to programming, this book is your comprehensive Ruby coding guide. Starting with the foundational principles, such as syntax, and scaling up to advanced topics such as big data analysis, this book will give you all of the tools you need to be a professional Ruby developer. A few of the key topics are: object-oriented programming, built-in Ruby methods, core programming skills, and an introduction to the Ruby on Rails and Sinatra web frameworks. You will also build 10 practical Ruby programs. Created by an experienced Ruby developer, this book has been written to ensure it focuses on the skills you will need to be a professional Ruby developer. After you have read this book, you will be ready to start building real-world Ruby projects.

What you will learn

• Learn how to use Ruby code effectively, picking the right tool for the job and not duplicating built-in functionality • Gain best software development practices, and how to identify and fix common errors • Absorb core programming skills, such as variables, strings, loops, conditionals, and much more • Explore object-oriented programming and learn to create modular, reusable code that you can use across projects • Build 10 practical Ruby programs as you work through the book on topics such as big data analysis and solving Euler equations

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 30, 2017
Length 330 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781787280649
Category :

Table of Contents

20 Chapters
Preface Chevron down icon Chevron up icon
Introduction to the Ruby Programming Language Chevron down icon Chevron up icon
Ruby Variables Chevron down icon Chevron up icon
Ruby Strings Chevron down icon Chevron up icon
Working with Numbers in Ruby Chevron down icon Chevron up icon
Ruby Methods Chevron down icon Chevron up icon
Ruby Iterators and Loops Chevron down icon Chevron up icon
Ruby Collections Chevron down icon Chevron up icon
Ruby Conditionals Chevron down icon Chevron up icon
Object-Oriented Programming in Ruby Chevron down icon Chevron up icon
Working with the Filesystem in Ruby Chevron down icon Chevron up icon
Error Handling in Ruby Chevron down icon Chevron up icon
Regular Expressions in Ruby Chevron down icon Chevron up icon
Searching with grep in Ruby Chevron down icon Chevron up icon
Ruby Gems Chevron down icon Chevron up icon
Ruby Metaprogramming Chevron down icon Chevron up icon
Ruby Web Frameworks Chevron down icon Chevron up icon
Working with APIs in Ruby Chevron down icon Chevron up icon
Ruby Algorithms Chevron down icon Chevron up icon
Machine Learning Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.