Book description
Cut through the noise and get real results with a step-by-step approach to learning Ruby programming.
Key Features
- Ideal for the Ruby beginner who is getting started with Ruby for the first time
- A complete Ruby tutorial with exercises and activities that help build key skills
- Structured to let you progress at your own pace, on your own terms
- Use your physical copy to redeem free access to the online interactive edition
Book Description
You already know you want to learn Ruby, and the smarter way to learn Ruby 2.X is to learn by doing. The Ruby Workshop focuses on building up your practical skills so that you can kick-start your career as a developer and rapidly prototype applications. You'll learn from real examples that lead to real results.
Throughout The Ruby Workshop, you'll take an engaging step-by-step approach to understanding the Ruby language. You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about metaprogramming. It's your choice. Learning on your terms, you'll build up and reinforce key skills in a way that feels rewarding.
Every physical copy of The Ruby Workshop unlocks access to the interactive edition. With videos detailing all exercises and activities, you'll always have a guided solution. You can also benchmark yourself against assessments, track progress, and receive content updates. You'll even earn a secure credential that you can share and verify online upon completion. It's a premium learning experience that's included with your printed copy. To redeem, follow the instructions located at the start of your Ruby book.
Fast-paced and direct, The Ruby Workshop is the ideal companion for Ruby beginners. You'll build and iterate on your Ruby code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead.
What you will learn
- Get to grips with the fundamentals of Ruby object-oriented programming
- Understand common Ruby patterns to help minimize and easily maintain code
- Explore ways to fetch, process, and output external data
- Discover ways to work with public APIs and create reusable RubyGems
- Keep your development process bug-free with various testing methods
- Explore how to host applications on cloud application platforms like Heroku
Who this book is for
Our goal at Packt is to help you be successful, in whatever it is you choose to do. The Ruby Workshop is an ideal Ruby tutorial for the Ruby beginner who is just getting started. Pick up a Workshop today, and let Packt help you develop skills that stick with you for life.
Table of contents
- Preface
-
1. Writing and Running Ruby Programs
- Introduction
-
Interactive Ruby Shell (IRB)
- Exercise 1.01: Creating and Assigning Variables
- Exercise 1.02: Assigning a Variable of One Data Type to a Different Type
- Exercise 1.03: Getting the Type of a Variable
- Getting the Details of the Public Methods of an Object
- Running Ruby Code from Ruby Files
- Exercise 1.04: Getting User Input in a Ruby Program
-
Standard Data Types
- Number
- Exercise 1.05: Performing Common Integer Operations
- Exercise 1.06: Using Common Integer Methods to Perform Complex Arithmetic
- Floating-Point Numbers
- Exercise 1.07: Performing Common Operations for Floating-Point Numbers
- String
- Exercise 1.08: Using Common String Methods
- Exercise 1.09: Performing String Concatenation
- Exercise 1.10: Performing String Interpolation
- Exercise 1.11: Extracting and Searching a Substring from a String
- Exercise 1.12: Replacing Part of a String with Another String
- Exercise 1.13: Replacing All the Values inside a String Using gsub
- Exercise 1.14: Splitting a String and Joining a String
- Activity 1.01: Generating Email Addresses Using Ruby
- Boolean
- Activity 1.02: Calculating the Area and Perimeter of a Candy Manufacturing Plant
- Summary
- 2. Ruby Data Types and Operations
- 3. Program Flow
- Ruby Methods
- 5. Object-Oriented programming with Ruby
-
6. Modules and Mixins
- Introduction
- Including Modules
-
extend
- Exercise 6.02: Extending Your Modules with Class and Instance Methods
- Module Callbacks
- Exercise 6.03: Using Module Functions to Extend Classes
- Importing Modules as Class Methods using Extended
- Combining include and extend
- Enumerated Types
- Exercise 6.04: Writing a Module to Define Payment Methods for a Product Application
- Module Methods
- Namespaces
- prepend
- Summary
- 7. Introduction to Ruby Gems
-
8. Debugging with Ruby
- Introduction
- Logging and Debugging
- Basic Logging
-
Debugging
- Debugging Concepts
- Debugging via the CLI with byebug
- Conditional Debugging
- Navigating with byebug
- Exercise 8.04: Debugging with byebug
- Debugging with Visual Studio Code
- Setting Breakpoints
- Logpoints
- The Debug Console
- Exercise 8.05: Debugging with Visual Studio Code
- Activity 8.01: Perform Debugging on a Voting Application
- Summary
-
9. Ruby Beyond the Basics l
- Introduction
-
Metaprogramming
- Blocks
- Syntax for Blocks
- yield with Blocks
- Exercise 9.01: Building a Simple Calculator
- block_given? with Blocks
- Exercise 9.02: Building a Flight Status Display System
- The proc Object
- Exercise 9.03: Performing the sum Function on a Range of Numbers
- Exercise 9.04: Calculating Profit Using proc on an Input Price List
- Lambdas
- Exercise 9.05: Creating a Program to Sum a Range of Numbers Using Lambdas
- proc versus lambda
- The Story of the Chef and the Restaurant
- Activity 9.01: Invoice Generator
- Summary
-
10. Ruby Beyond the Basics ll
- Introduction
-
Metaprogramming – A Deep Dive
- Opening Classes
- Exercise 10.01: Opening the Ruby String Class to Add a New Method to it
- Monkey Patching
- Exercise 10.02: Using Monkey Patching to Add/Subtract Values
- method_missing
- Exercise 10.03: Managing Ghost Methods for the Company Class
- The Define Method
- Exercise 10.04: Creating a Welcome Message Program Using define_method
- HTTP Requests
- Creating a Ruby Gem
- Summary
- 11. Introduction to Ruby on Rails l
-
12. Introduction to Ruby on Rails ll
- Introduction
- Associations
-
Validations
- Database Validations
- Controller-Level Validations
- Client-Side Validations
- Model-Level Validations
- Methods that Trigger Validations
- Methods that Skip Validations
- Exercise 12.02: Adding Validation for the Citireview Application
- Scaffolding
- Exercise 12.03: Using Rails Scaffolding to Create a Rails Application for a Store with a List of Products
- Activity 12.01: Create a Blog Application and Host It Live on a Cloud Platform
- Summary
-
Appendix
- 1. Writing and Running Ruby Programs
- 2. Ruby Data Types and Operations
- 3. Program Flow
- 4. Ruby Methods
- 5. Object-Oriented Programming with Ruby
- 6. Modules and Mixins
- 7. Introduction to Ruby Gems
- 8. Debugging with Ruby
- 9. Ruby Beyond the Basics I
- 10. Ruby Beyond the Basics II
- 11. Introduction to Ruby on Rails I
- 12. Introduction to Ruby on Rails II
Product information
- Title: The Ruby Workshop
- Author(s):
- Release date: October 2019
- Publisher(s): Packt Publishing
- ISBN: 9781838642365
You might also like
book
Effective Ruby: 48 Specific Ways to Write Better Ruby
If you’re an experienced Ruby programmer, will help you harness Ruby’s full power to write more …
book
Ruby in a Nutshell
Ruby is an absolutely pure object-oriented scripting language written in C and designed with Perl and …
book
Ruby Best Practices
How do you write truly elegant code with Ruby? Ruby Best Practices is for programmers who …
book
Metaprogramming Ruby 2
Write powerful Ruby code that is easy to maintain and change. With metaprogramming, you can produce …