The Well-Grounded Rubyist
Covering Ruby 1.9
David A. Black
  • May 2009
  • ISBN 9781933988658
  • 520 pages
  • printed in black & white
This title is out of print and no longer for sale.

Ruby's inner workings, revealed by David Black.

Patrick Steger, Zühlke Engineering AG

Second edition of this book is available

The Well-Grounded Rubyist takes you from interested novice to proficient practitioner. It's a beautifully written tutorial that begins with the basic steps to get your first Ruby program up and running and goes on to explore sophisticated topics like callable objects, reflection, and threading The book concentrates on the language, preparing you for any way you may choose to use Ruby. Whether the topic is simple or tough, the book's easy-to-follow examples and explanations give you immediate confidence as you build your Ruby programming skills.

Table of Contents show full

preface

acknowledgments

about this book

about the cover illustration

Part 1 Ruby foundations 1

1. Chapter 1 Bootstrapping your Ruby literacy

1.1. Basic Ruby language literacy

1.2. Anatomy of the Ruby installation

1.3. Ruby extensions and programming libraries

1.4. Out-of-the-box Ruby tools and applications

1.5. Summary

2. Chapter 2 Objects, methods, and local variables

2.1. Talking to objects

2.2. Crafting an object: the behavior of a ticket

2.3. The innate behaviors of an object

2.4. A close look at method arguments

2.5. What you can’t do in argument lists

2.6. Local variables and variable assignment

2.7. Summary

3. Chapter 3 Organizing objects with classes

3.1. Classes and instances

3.2. Instance variables and object state

3.3. Setter methods

3.4. Attributes and the attr_* method family

3.5. Inheritance and the Ruby class hierarchy

3.6. Classes as objects and message receivers

3.7. Constants up close

3.8. Nature vs. nurture in Ruby objects

3.9. Summary

4. Chapter 4 Modules and program organization

4.1. Basics of module creation and use

4.2. Modules, classes, and method lookup

4.3. The method_missing method

4.4. Class/module design and naming

4.5. Summary

5. Chapter 5 The default object (self), scope, and visibility

5.1. Understanding self, the current/default object

5.2. Determining scope

5.3. Deploying method-access rules

5.4. Writing and using top-level methods

5.5. Summary

6. Chapter 6 Control-flow techniques

6.1. Conditional code execution

6.2. Repeating actions with loops

6.3. Iterators and code blocks

6.4. Error handling and exceptions

6.5. Summary

Part 2 Built-in classes and modules

7. Chapter 7 Built-in essentials

7.1. Ruby’s literal constructors

7.2. Recurrent syntactic sugar

7.3. Bang (!) methods and “danger”

7.4. Built-in and custom to_* (conversion) methods

7.5. Boolean states, boolean objects, and nil

7.6. Comparing two objects

7.7. Inspecting object capabilities

7.8. Summary

8. Chapter 8 Strings, symbols, and other scalar objects

8.1. Working with strings

8.2. Symbols and their uses

8.3. Numerical objects

8.4. Times and dates

8.5. Summary

9. Chapter 9 Collection and container objects

9.1. Arrays and hashes in comparison

9.2. Collection handling with arrays

9.3. Hashes

9.4. Ranges

9.5. Sets

9.6. Exploring the set.rb source code

9.7. Summary

10. Chapter 10 Collections central: Enumerable and Enumerator

10.1. Gaining enumerability through each

10.2. Enumerable boolean queries

10.3. Enumerable searching and selecting

10.4. Element-wise enumerable operations

10.5. The relatives of each

10.6. The map method

10.7. Strings as quasi-enumerables

10.8. Sorting enumerables

10.9. Enumerators and the next dimension of enumerability

10.10. Enumerator semantics and uses

10.11. Enumerator method chaining

10.12. Summary

11. Chapter 11 Regular expressions and regexp-based string operations

11.1. What are regular expressions?

11.2. Writing regular expressions

11.3. Building a pattern in a regular expression

11.4. Matching, substring captures, and MatchData

11.5. Fine-tuning regular expressions with quantifiers, anchors, and modifiers

11.6. Converting strings and regular expressions

to each other === Common methods that use regular expressions === Summary

12. Chapter 12 File, I/O, and system operations

12.1. How Ruby’s I/O system is put together

12.2. Basic file operations

12.3. Querying IO and File objects

12.4. Directory manipulation with the Dir class

12.5. File tools from the standard library

12.6. Summary

Part 3 Ruby dynamics

13. Chapter 13 Object individuation

13.1. Where the singleton methods are: the singleton class

13.2. Modifying Ruby’s core classes and modules

13.3. BasicObject as ancestor and class

13.4. Summary

14. Chapter 14 Callable and runnable objects

14.1. Basic anonymous functions: the Proc class

14.2. Creating functions with lambda and →

14.3. Methods as objects

14.4. The eval family of methods

14.5. Parallel execution with threads

14.6. Issuing system commands from inside Ruby programs

14.7. Summary

15. Chapter 15 Callbacks, hooks, and runtime introspection

15.1. Callbacks and hooks

15.2. Interpreting object capability queries

15.3. Introspection of variables and constants

15.4. Tracing execution

15.5. Callbacks and method inspection in practice

15.6. Summary

© 2014 Manning Publications Co.

About the Technology

Interest in Ruby has exploded. Developers discovering this elegant, dynamic language quickly learn that Ruby is a powerful alternative to traditional static languages like Java or C++. It runs in most operating environments and can handle virtually any programming task you throw at it. Ruby code is clean and elegant. Best of all, Ruby is dynamic, which means that it's designed to react at runtime to changes in an application's environment or requirements.

About the book

The Well-Grounded Rubyist is a thoroughly revised and updated edition of the best-selling Ruby for Rails. In this new book, expert author David A. Black moves beyond Rails and presents a broader view of Ruby. It covers Ruby 1.9, and keeps the same sharp focus and clear writing that made Ruby for Rails stand out.

It's no wonder one reader commented: "The technical depth is just right to not distract beginners, yet detailed enough for more advanced readers."

What's inside

  • Crystal clear examples and explanations of core Ruby topics
  • Starts at the very beginning and guides you to confident proficiency
  • Updated for Ruby 1.9
  • Prepares you to use Ruby anywhere—not just with Rails

About the author

David A. Black has been programming in Ruby since 2000. He is the owner and director of the consultancy Ruby Power and Light, LLC, and a director of Ruby Central, Inc. David is a Ruby library contributor, and an expert practitioner and trainer in the Ruby language and the Ruby on Rails development framework.