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)

Ruby OOP development – setters, getters, and methods

Ruby utilizes a unique syntax for creating setters and getters in a class. In this guide, we will walk through how to implement these processes.

Creating a class is fairly simple in Ruby. It's so simple that it wasn't even worth dedicating an entire guide to it (I build courses just like I code, I despise wasting my time or yours for dead simple concepts).

To define a class simply type the class word followed by the name you want to give to your class, and end it with the end word. Anything contained between class and end belongs to this class.

Class names in Ruby have a very specific style requirement. They need to start with a letter and if they represent multiple words, each new word needs also to be an uppercase letter.

We'll start by creating a class called ApiConnector:

class ApiConnector
end

Now...