1 Bootstrapping your Ruby literacy
This chapter covers
- A Ruby syntax survival kit
- Writing, saving, running, and error-checking programs
- A tour of the Ruby installation
- The mechanics of Ruby extensions
- Ruby’s command-line tools such as irb and rake
This book will give you a foundation in Ruby. It’s organized to first provide the fundamental building blocks of the language; then adds a study of higher-order classes and modules; and finishes by teaching you how to apply what you’ve learned through advanced Ruby techniques and program design. The Well-Grounded Rubyist, Fourth Edition is written for the reader who’s done some programming and perhaps even some Ruby and wants to learn more about the Ruby language. In reading this book, you’re going on a journey with us to learn not only specific techniques but also the design principles and richness of the language. We love Ruby and we hope to impart not just the specifics of the language we love but also why we love it.
1.1 Basic Ruby language literacy
1.1.1 Installing Ruby and using a text editor
1.1.2 A Ruby syntax survival kit
1.1.3 The variety of Ruby identifiers
1.1.4 Method calls, messages, and Ruby objects
1.1.5 Writing and saving a simple program
1.1.6 Feeding the program to Ruby
1.1.7 Keyboard and file I/O
1.2 Anatomy of the Ruby installation
1.2.1 The Ruby standard library subdirectory (RbConfig::CONFIG[“rubylibdir”])
1.2.2 The C extensions directory (RbConfig::CONFIG[“archdir”])
1.2.3 The site_ruby (RbConfig::CONFIG[“sitedir”]) and vendor_ruby (RbConfig::CONFIG[“vendordir”]) directories
1.2.4 Standard Ruby gems and the gems directory
1.3 Ruby extensions and programming libraries
1.3.1 Loading external files and extensions
1.3.2 “Load”-ing a file in the default load path
1.3.3 “Require”-ing a feature
1.3.4 require_relative
1.4 Out-of-the-box Ruby tools and applications
1.4.1 Interpreter command-line switches
1.4.2 A closer look at interactive Ruby interpretation with irb
1.4.3 The rake task-management utility
1.4.4 Installing packages with the gem command
1.4.5 Interactive debugging with rdbg
1.5 Summary