Book Image

Comprehensive Ruby Programming

By : Jordan Hudgens
Book Image

Comprehensive Ruby Programming

By: Jordan Hudgens

Overview of this book

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.
Table of Contents (20 chapters)

What this book covers

Chapter 1, Introduction to the Ruby Programming Language, gives a high-level view of the Ruby programming language, how to install it on your system, and getting it up and running so you can start building Ruby programs.

Chapter 2, Ruby Variables, teaches you how to work with variables in Ruby to store data and use the data throughout a program, because Ruby variables are the building blocks of just about every Ruby program.

Chapter 3, Ruby Strings, teaches about the Ruby string data type and walks you through how to integrate string data into a Ruby program. Working with words, sentences, and paragraphs are common requirements in many applications.

Chapter 4, Working with Numbers in Ruby, explains how to work with different number data types in a Ruby program, including the integer and float types. A key component in building programs is developing mathematical equations in order to implement various algorithms.

Chapter 5, Ruby Methods, teaches how to create and use methods in Ruby programs to store processes and reuse them throughout a program, including an overview of procs and lambdas. One of the most powerful tools available to developers is the ability to store functionality and share that behavior throughout a program.

Chapter 6, Ruby Iterators and Loops, works you through the powerful iteration tools that come with the Ruby programming language that allow you to traverse various collection types. When it comes to developing programs, one of the common tools utilized by programmers is the ability to loop through collections of data.

Chapter 7, Ruby Collections, shows that nearly every application that you will build will need to implement collections of data in some form or another. This could be anything from a database query that returns multiple records to a set of dates in a calendar.

Chapter 8, Ruby Conditionals, teaches how to integrate conditionals into a Ruby program, which will enable your programs to have dynamic behavior based on different input data. A key component for building dynamic behavior into Ruby applications requires conditional logic at some stage or another.

Chapter 9, Object-Oriented Programming in Ruby, teaches you Object-Oriented Programming (OOP) for Ruby, including creating classes, instantiating objects, working with inheritance, and polymorphism. In addition to readability, one of the defining attributes of the Ruby programming language is how it implements OOP techniques.

Chapter 10, Working with the Filesystem in Ruby, reveals various ways to work with files in Ruby, including the ability to create, open, edit, and delete files using built-in methods and classes.

Chapter 11, Error Handling in Ruby, explains how to work with errors in Ruby, including how to build practical tools such as an error logging program. Many new developers are intimidated when they come across errors and exceptions in a program. However, errors are Ruby's way of telling you how you can improve or alter your program to work properly.

Chapter 12, Regular Expressions in Ruby, enables you to work with regular expressions in Ruby, including the built in Regex class that allows you to build matchers and dynamically search through data. Pattern matching is a common requirement for building code libraries such as validations and basic search functionality.

Chapter 13, Searching with grep in Ruby, teaches how to use the powerful grep method in Ruby programs in order to search through data. Ruby offers a wide variety of options when it comes to searching through strings.

Chapter 14, Ruby Gems, walks you through and teaches what Ruby gems are, how to use them, and where you can find new gems to give your Ruby programs additional functionality. One of the reasons for Ruby's growth in popularity over the past decade is the open source community building code libraries that can be implemented in other applications. Typically, these code libraries are called Ruby gems.

Chapter 15, Ruby Metaprogramming, explains some of the basics of metaprogramming in Ruby, including how to open classes and add functionality to built-in Ruby classes. Writing code that writes code is one of the more challenging topics in any programming language. However, metaprogramming in Ruby offers such a powerful interface for building advanced features into an application. It is worth the effort to learn it.

Chapter 16, Ruby Web Frameworks, reveals the two most popular web frameworks for Ruby programs, Rails and Sinatra, including building applications for both frameworks.

Chapter 17, Working with APIs in Ruby, walks you through how to work with APIs and build a Ruby program that communicates with a third-party API and parses the JSON data. Working with outside services is a powerful mechanism for building data-driven applications.

Chapter 18, Ruby Algorithms, puts together all of the knowledge that we've compiled in the book in order to implement popular algorithms. Specifically, you'll learn how to build advanced algorithms in the Ruby programming language, including the sorting methods, such as quick sort and merge sort, along with a number of functional programming algorithms.

Chapter 19, Machine Learning, teaches how to integrate machine learning algorithms into a Ruby program, including how to build a decision tree, train it, and have it output dynamic results. One of the fastest growing sectors in development is machine learning.