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)

Creating methods in Ruby

Methods are a powerful feature for building Ruby programs. They allow you to encapsulate behavior and call the method later on to build the functionality of programs. This is an important section, as you are going to learn about methods in Ruby.

Before we walk through the syntax guide, I want to show you a real-world Rails application code file called the jobs_controller.rb:

Each one of the items, such as index, show, edit, and create, are methods. As you may notice, there are many methods in a file, and each of them performs a specific task, behavior, or action. You are going to be using these methods day in and day out as a Ruby developer, so it's important you have a firm grasp on what the concept is.

Methods have a specific syntax. They begin with the def word followed by the name of your method. In general, your method name should reflect its...