Programming Ruby: The Pragmatic Programmers' Guide (Pragmatic Programmers Series) / Edition 2
  • Alternative view 1 of Programming Ruby: The Pragmatic Programmers' Guide (Pragmatic Programmers Series) / Edition 2
  • Alternative view 2 of Programming Ruby: The Pragmatic Programmers' Guide (Pragmatic Programmers Series) / Edition 2

Programming Ruby: The Pragmatic Programmers' Guide (Pragmatic Programmers Series) / Edition 2

4.5 4
by Dave Thomas, Chad Fowler, Andy Hunt

ISBN-10: 0974514055

ISBN-13: 9780974514055

Pub. Date: 10/28/2004

Publisher: Pragmatic Programmers, LLC, The

Ruby is an increasingly popular, fully object-oriented dynamic programming language, hailed by many practitioners as the finest and most useful language available today. When Ruby first burst onto the scene in the Western world, the Pragmatic Programmers were there with the definitive reference manual, Programming Ruby: The Pragmatic Programmer's


Ruby is an increasingly popular, fully object-oriented dynamic programming language, hailed by many practitioners as the finest and most useful language available today. When Ruby first burst onto the scene in the Western world, the Pragmatic Programmers were there with the definitive reference manual, Programming Ruby: The Pragmatic Programmer's Guide.

Now in its second edition, author Dave Thomas has expanded the famous Pickaxe book with over 200 pages of new content, covering all the improved language features of Ruby 1.8 and standard library modules. The Pickaxe contains four major sections:

  • An acclaimed tutorial on using Ruby.
  • The definitive reference to the language.
  • Complete documentation on all built-in classes, modules, and methods
  • Complete descriptions of all 98 standard libraries.

If you enjoyed the First Edition, you'll appreciate the expanded content, including enhanced coverage of installation, packaging, documenting Ruby source code, threading and synchronization, and enhancing Ruby's capabilities using C-language extensions. Programming for the World Wide Web is easy in Ruby, with new chapters on XML/RPC, SOAP, distributed Ruby, templating systems, and other web services. There's even a new chapter on unit testing.

This is the definitive reference manual for Ruby, including a description of all the standard library modules, a complete reference to all built-in classes and modules (including more than 250 significant changes since the First Edition). Coverage of other features has grown tremendously, including details on how to harness the sophisticated capabilities of irb, so you can dynamically examine and experiment with your running code. "Ruby is a wonderfully powerful and useful language, and whenever I'm working with it this book is at my side" —Martin Fowler, Chief Scientist, ThoughtWorks

Product Details

Pragmatic Programmers, LLC, The
Publication date:
Pragmatic Programmers Series
Edition description:
Second Edition
Product dimensions:
7.40(w) x 9.38(h) x 1.56(d)

Table of Contents

Foreword to the First Editionxxi
Foreword to the Second Editionxxiii
Road Mapxxxi
Part IFacets of Ruby
1Getting Started3
Installing Ruby3
Running Ruby5
Ruby Documentation: RDoc and ri8
Ruby Is an Object-Oriented Language11
Some Basic Ruby13
Arrays and Hashes16
Control Structures18
Regular Expressions19
Blocks and Iterators21
Reading and 'Riting23
Onward and Upward24
3Classes, Objects, and Variables25
Inheritance and Messages27
Objects and Attributes29
Class Variables and Class Methods33
Access Control37
4Containers, Blocks, and Iterators43
Blocks and Iterators49
Containers Everywhere57
5Standard Types59
Regular Expressions68
6More about Methods79
Defining a Method79
Calling a Method81
Operator Expressions88
Miscellaneous Expressions89
Conditional Execution93
Case Expressions98
Variable Scope, Loops, and Blocks105
8Exceptions, Catch, and Throw107
The Exception Class107
Handling Exceptions108
Raising Exceptions112
Catch and Throw114
Iterators and the Enumerable Module120
Composing Modules120
Including Other Files123
10Basic Input and Output127
What Is an IO Object?127
Opening and Closing Files128
Reading and Writing Files129
Talking to Networks133
11Threads and Processes135
Controlling the Thread Scheduler140
Mutual Exclusion141
Running Multiple Processes147
12Unit Testing151
Test::Unit Framework152
Structuring Tests156
Organizing and Running Tests159
13When Trouble Strikes163
Ruby Debugger163
Interactive Ruby164
Editor Support165
But It Doesn't Work!167
But It's Too Slow!170
Part IIRuby in Its Setting
14Ruby and Its World177
Command-Line Arguments177
Program Termination180
Environment Variables181
Where Ruby Finds Its Modules182
Build Environment183
15Interactive Ruby Shell185
Command Line185
Rtags and xmp196
16Documenting Ruby199
Adding RDoc to Ruby Code199
Adding RDoc to C Extensions207
Running RDoc211
Displaying Program Usage212
17Package Management with RubyGems215
Installing RubyGems216
Installing Application Gems216
Installing and Using Gem Libraries218
Creating Your Own Gems223
18Ruby and the Web235
Writing CGI Scripts235
Improving Performance247
Choice of Web Servers247
SOAP and Web Services249
More Information253
19Ruby TK255
Simple TK Application255
Binding Events260
Translating from Perl/TK Documentation265
20Ruby and Microsoft Windows267
Getting Ruby for Windows267
Running Ruby Under Windows268
Windows Automation269
21Extending Ruby275
Your First Extension275
Ruby Objects in C278
The Jukebox Extension284
Memory Allocation293
Ruby Type System294
Creating an Extension296
Embedding a Ruby Interpreter301
Bridging Ruby to Other Languages304
Ruby C Language API305
Part IIIRuby Crystallized
22The Ruby Language317
Source Layout317
The Basic Types319
Variables and Constants330
Method Definition345
Invoking a Method348
Class Definition352
Module Definitions354
Access Control356
Blocks, Closures, and Proc Objects356
Catch and Throw362
23Duck Typing365
Classes Aren't Types366
Coding like a Duck370
Standard Protocols and Coercions371
Walk the Walk, Talk the Talk377
24Classes and Objects379
How Classes and Objects Interact379
Class and Module Definitions387
Top-Level Execution Environment393
Inheritance and Visibility393
Freezing Objects394
25Locking Ruby in the Safe397
Safe Levels398
Tainted Objects399
26Reflection, ObjectSpace, and Distributed Ruby403
Looking at Objects404
Looking at Classes405
Calling Methods Dynamically407
System Hooks410
Tracing Your Program's Execution412
Marshaling and Distributed Ruby414
Compile Time? Runtime? Anytime!419
Part IVRuby Library Reference
27Built-in Classes and Modules423
Alphabetical Listing424
28Standard Library653
Part VAppendixes
ASocket Library763
BMkmf Reference779
Web Sites783
Download Sites784
Usenet Newsgroup784
Mailing Lists784
Summary Tables824

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >

Programming Ruby: The Pragmatic Programmers' Guide (Pragmatic Programmers Series) 4.5 out of 5 based on 0 ratings. 4 reviews.
Guest More than 1 year ago
I found this book to be very well written and concise, though clearly intended for someone with some level of prior programming experience. My only real complaint is that some of the chapters, while covering a wide amount of material, seem to be lacking in depth. Aside from that, however, I found this book to be more than adequate to give a solid a foundation in Ruby, and after it serves as an extremely useful reference for the classes and modules that are built-in to Ruby. All in all, if you're interested in learning Ruby, this book should definitely be in your collection.
Guest More than 1 year ago
When Dave Thomas and Andy Hunt, authors of The Pragmatic Programmer, published the first edition of Programming Ruby in 2000, it was the first English language Ruby book. Ruby documentation was so scant that they had to study the source code to do it, as Ruby's author, Matz, explains in his foreword. For 2005, they revised it to cover Ruby 1.8, the latest major release. Though there are now several other Ruby books, Programming Ruby is still trying to do it all -- language tutorial, language reference, a guide to thinking in Ruby (which includes thinking in objects), and an introduction to the Ruby community's conventions. The book is broader than it is deep, but, given its breadth, that's praising with faint damns. It's not a book for a programming novice, but the language tutorial was thorough and clear. Moderately experienced programmers should have no problems with it. If you've done object-oriented and functional programming before, it'll be easy going. I was impressed by how much the book includes of what you need to actually _develop_ in Ruby -- trying code snippets in the interactive Ruby shell, debugging, watching out for Ruby's gotchas, developing a test suite, documenting (in Rdoc, a Ruby standard), packaging code into a Ruby Gem (RubyGems is Ruby's equivalent to Perl's CPAN), profiling your code to find the slow parts, and how to extend Ruby in C to speed them up. There's a brief survey of using Ruby for Web, Tk, and Win32 programming. The book's emphasis on breadth over depth is most obvious here -- 18 pages on web programming doesn't just cover CGI programming, but touches on cookies, session maintenance, two template systems for HTML generation, eruby (a means of embedding Ruby in HTML, like PHP, Mason, PSP, or the other *SPs), SOAP, WSDL, and the Google API. (Ruby on Rails is mentioned only as a framework 'currently attracting mindshare in the Ruby community.') For all their brevity, these chapters were still useful. They're a starting point for learning available tools for those problem domains. More importantly, they demonstrate the breadth of the standard library and other available packages, and provide a lesson in looking for existing solutions first. That's old hat to people used to the open source world, but it could prove invaluable to someone who wandered in from the outside. Almost half the book is a reference to the built-in classes and modules, and to the standard library. Ruby has dozens of built-in classes, each, typically, with dozens of methods, so it's no surprise that a lot of this information went unmentioned in the language tutorial. In my use of the reference so far, I've found it clear and well-organized. Perl played a part in inspiring Ruby. Likewise, it strikes me that Programming Ruby's authors probably took inspiration from Programming Perl. It's even nicknamed for its cover illustration -- the PickAxe Book. And, like the Camel Book, it goes beyond the language at hand to advance general principles of good programming: code reuse, writing for maintainability, and avoiding reinventing the wheel. And it's all written with an infectious joy in programming. My only complaint about the book is that the index is spotty in its coverage of the language tutorial chapters -- I've felt frustrated trying to find discussions of things because, too often, the index only pointed to the reference section's coverage of them. But the book left me excited about programming in Ruby, and gave me all I needed to begin. That's all I could ask from an introduction to a new language.
Guest More than 1 year ago
Overall, I like this book. If you are new to Ruby, I would recommend it. The book takes you through a process (like a long tutorial). The last part of the book is strictly reference material. The bad thing is that if you are new to OOP and new to Ruby, you might find it leaves out too many details or just doesn't quite cover them in the depth you might require. I like the book. But, I think I'll have to continue to use Google to supplement it. The previous review critcized the Ruby language. In response to it, I will say that Ruby is the epitomy of OOP (though maybe not quite as much as SmallTalk). I haven't used Java or Perl. So, I'm not qualified to compare those. But, so far, Ruby seems to make alot of sense to me.
Guest More than 1 year ago
Yet another scripting language. Originating in Japan, its inventor (Y Matsumoto) claims that it is more powerful than Perl and more object oriented than Python. Somehow, I imagine proponents of those languages might vociferously disagree. In any event, Thomas does a nice job of documenting Ruby, for the benefit of a newcomer. A key strength of Ruby seems to be what it calls containers, blocks and iterators. This includes a nice ability to have hash tables. Certainly, you have more to start with than in a bare bones language like C. Veterans of Java will recognise and appreciate this native Ruby functionality. The importance of these functions can be seen in the unusual order in which they appear in the book. Thomas discusses these in a chapter that precedes talking about mundane and simpler things like the standard variable types, operators and loops. Most texts of any language would reverse the order. Overall, I am ambivalent about Ruby. Not so much because I disagree with what Thomas says, as simply because I'm quite comfortable in Java. Nonetheless, if you are casting around for a strong OO scripting language, Ruby might be worth consideration.