| Foreword | | xix | |
| About the Author | | xxiii | |
| About the Technical Reviewers | | xxv | |
| Acknowledgments | | xxvii | |
| Introduction | | xxix | |
| PART 1 Foundations and Scaffolding |
| |
| Let's Get It Started: Installing Ruby |
| | 3 | |
| | 4 | |
| | 4 | |
| | 7 | |
| | 10 | |
| | 12 | |
| | 13 | |
| Programming == Joy: A Whistle-Stop Tour of Ruby and Object Orientation |
| | 15 | |
| | 16 | |
| | 16 | |
| Ruby Is English for Computers |
| | 17 | |
| Why Ruby Makes a Great Programming Language |
| | 17 | |
| | 18 | |
| Turning Ideas into Ruby Code |
| | 20 | |
| How Ruby Understands Concepts with Objects and Classes |
| | 20 | |
| | 21 | |
| | 23 | |
| | 24 | |
| | 27 | |
| | 29 | |
| | 29 | |
| Using the Methods of the String Class |
| | 31 | |
| Using Ruby Without Object Orientation |
| | 32 | |
| | 33 | |
| Ruby's Building Blocks: Data, Expressions, and Flow Control |
| | 35 | |
| | 35 | |
| | 35 | |
| | 36 | |
| Comparison Operators and Expressions |
| | 38 | |
| Looping Through Numbers with Blocks and Iterators |
| | 40 | |
| | 42 | |
| | 43 | |
| | 44 | |
| | 44 | |
| | 46 | |
| | 47 | |
| | 49 | |
| Regular Expressions and String Manipulation |
| | 50 | |
| | 57 | |
| | 58 | |
| Splitting Strings into Arrays |
| | 60 | |
| | 61 | |
| | 62 | |
| | 65 | |
| | 66 | |
| | 67 | |
| | 68 | |
| | 69 | |
| | 70 | |
| | 71 | |
| | 72 | |
| | 74 | |
| Other Useful Building Blocks |
| | 76 | |
| | 76 | |
| | 80 | |
| | 81 | |
| | 83 | |
| Converting Between Classes |
| | 84 | |
| | 85 | |
| Developing a Basic Ruby Application |
| | 87 | |
| Working with Source Code Files |
| | 87 | |
| | 88 | |
| The Test Source Code File |
| | 90 | |
| | 90 | |
| Our Application: A Text Analyzer |
| | 93 | |
| | 94 | |
| Building the Basic Application |
| | 94 | |
| Obtaining Some Dummy Text |
| | 95 | |
| Loading Text Files and Counting Lines |
| | 95 | |
| | 97 | |
| | 98 | |
| Counting Sentences and Paragraphs |
| | 100 | |
| | 102 | |
| | 102 | |
| | 103 | |
| Percentage of ``Useful'' Words |
| | 103 | |
| Summarizing by Finding ``Interesting'' Sentences |
| | 105 | |
| Analyzing Files Other Than text.txt |
| | 107 | |
| | 108 | |
| | 111 | |
| | 113 | |
| | 113 | |
| The Land of the Rising Sun |
| | 114 | |
| | 115 | |
| | 115 | |
| | 117 | |
| Why Rails Came into Existence |
| | 118 | |
| How the Web (2.0) Was Won |
| | 119 | |
| | 119 | |
| | 120 | |
| Where and How to Get Help |
| | 121 | |
| | 121 | |
| | 121 | |
| Internet Relay Chat (IRC) |
| | 122 | |
| | 123 | |
| | 124 | |
| | 124 | |
| | 124 | |
| | 125 | |
| | 125 | |
| | 126 | |
| |
| Classes, Objects, and Modules |
| | 129 | |
| Why Use Object Orientation? |
| | 129 | |
| Object Orientation Basics |
| | 133 | |
| Local, Global, Object, and Class Variables |
| | 133 | |
| Class Methods vs. Object Methods |
| | 138 | |
| | 140 | |
| Overriding Existing Methods |
| | 143 | |
| Reflection and Discovering an Object's Methods |
| | 145 | |
| | 146 | |
| | 151 | |
| | 153 | |
| | 154 | |
| Modules, Namespaces, and Mix-Ins |
| | 156 | |
| | 156 | |
| | 159 | |
| Building a Dungeon Text Adventure with Objects |
| | 168 | |
| | 168 | |
| Creating the Initial Classes |
| | 168 | |
| Structs: Quick and Easy Data Classes |
| | 170 | |
| | 173 | |
| | 173 | |
| | 178 | |
| | 181 | |
| Projects and Using Code from Other Files |
| | 181 | |
| | 181 | |
| Inclusions from Other Directories |
| | 184 | |
| | 185 | |
| | 185 | |
| | 186 | |
| | 187 | |
| | 189 | |
| | 198 | |
| Documentation, Error Handling, Debugging, and Testing |
| | 201 | |
| | 201 | |
| Generating Documentation with RDoc |
| | 202 | |
| | 203 | |
| | 208 | |
| Exceptions and Error Handling |
| | 208 | |
| | 212 | |
| | 213 | |
| | 216 | |
| The Philosophy of Test-Driven Development |
| | 217 | |
| | 219 | |
| More Test: Unit Assertions |
| | 221 | |
| Benchmarking and Profiling |
| | 222 | |
| | 223 | |
| | 225 | |
| | 227 | |
| | 229 | |
| | 229 | |
| | 230 | |
| | 231 | |
| | 248 | |
| | 248 | |
| Storing Objects and Data Structures |
| | 251 | |
| Relational Databases and SQL |
| | 255 | |
| Relational Database Concepts |
| | 256 | |
| The Big Four: MySQL, PostgreSQL, Oracle, and SQLite |
| | 257 | |
| | 258 | |
| A Crash Course in Basic Database Actions and SQL |
| | 259 | |
| | 264 | |
| Connecting to Other Database Systems |
| | 269 | |
| ActiveRecord: A Sneak Peek |
| | 274 | |
| | 275 | |
| Deploying Ruby Applications and Libraries |
| | 279 | |
| Distributing Basic Ruby Programs |
| | 279 | |
| | 280 | |
| Associated File Types in Windows |
| | 282 | |
| | 282 | |
| Detecting Ruby's Runtime Environment |
| | 284 | |
| Easy OS Detection with Ruby_Platform |
| | 285 | |
| | 285 | |
| Accessing Command Line Arguments |
| | 287 | |
| Distributing and Releasing Ruby Libraries As Gems |
| | 288 | |
| | 289 | |
| | 293 | |
| | 294 | |
| Deploying Ruby Applications As Remote Services |
| | 295 | |
| | 295 | |
| | 298 | |
| | 303 | |
| | 308 | |
| | 309 | |
| | 309 | |
| | 310 | |
| | 311 | |
| Creating Your Own Version of attr_accessor |
| | 314 | |
| Running Other Programs from Ruby |
| | 315 | |
| Getting Results from Other Programs |
| | 315 | |
| Transferring Execution to Another Program |
| | 316 | |
| Running Two Programs at the Same Time |
| | 316 | |
| Interacting with Another Program |
| | 317 | |
| Safely Handling Data and Dangerous Methods |
| | 318 | |
| | 319 | |
| | 321 | |
| Working with Microsoft Windows |
| | 322 | |
| | 323 | |
| Controlling Windows Programs |
| | 325 | |
| | 327 | |
| Basic Ruby Threads in Action |
| | 328 | |
| Advanced Thread Operations |
| | 329 | |
| | 331 | |
| Why Use C As an Inline Language? |
| | 332 | |
| Creating a Basic Method or Function |
| | 332 | |
| | 334 | |
| Unicode and UTF-8 Support |
| | 336 | |
| | 339 | |
| Tying It Together: Developing a Larger Ruby Application |
| | 341 | |
| | 341 | |
| | 341 | |
| | 343 | |
| | 343 | |
| Creating a Text Processing Tools Library |
| | 344 | |
| Building the WordPlay Library |
| | 345 | |
| | 351 | |
| | 354 | |
| | 357 | |
| The Program's Life Cycle and Parts |
| | 358 | |
| | 360 | |
| Constructing the Bot Class and Data Loader |
| | 363 | |
| | 365 | |
| | 371 | |
| | 374 | |
| | 375 | |
| | 378 | |
| | 378 | |
| Using Text Files As a Source of Conversation |
| | 379 | |
| Connecting the Bot to the Web |
| | 379 | |
| | 382 | |
| | 384 | |
| |
| Ruby on Rails: Ruby's Killer App |
| | 387 | |
| | 387 | |
| What Is Rails and Why Use It? |
| | 387 | |
| | 389 | |
| | 391 | |
| Building a Basic Rails Applications |
| | 391 | |
| Creating a Blank Rails Application |
| | 391 | |
| | 396 | |
| Creating a Model and Migrations |
| | 398 | |
| | 404 | |
| | 408 | |
| | 418 | |
| | 420 | |
| | 422 | |
| | 424 | |
| | 424 | |
| | 426 | |
| | 428 | |
| References and Demo Applications |
| | 429 | |
| Reference Sites and Tutorials |
| | 429 | |
| Example Rails Applications |
| | 430 | |
| | 430 | |
| | 433 | |
| | 433 | |
| | 433 | |
| Generating Web Pages and HTML |
| | 443 | |
| | 448 | |
| | 454 | |
| | 454 | |
| | 456 | |
| Sending Mail with ActionMailer |
| | 457 | |
| | 458 | |
| Connection and Basic FTP Actions |
| | 459 | |
| | 461 | |
| | 462 | |
| | 464 | |
| Networking, Sockets, and Daemons |
| | 467 | |
| | 467 | |
| | 468 | |
| | 468 | |
| | 469 | |
| Checking Machine and Service Availability |
| | 469 | |
| | 471 | |
| Connecting to a TCP Server Directly |
| | 474 | |
| | 475 | |
| | 475 | |
| Building a Simple TCP Server |
| | 478 | |
| | 480 | |
| | 482 | |
| A GServer-Based Chat Server |
| | 485 | |
| | 488 | |
| | 488 | |
| | 490 | |
| Useful Ruby Libraries and Gems |
| | 493 | |
| | 494 | |
| | 494 | |
| | 494 | |
| | 495 | |
| | 496 | |
| | 496 | |
| | 496 | |
| | 499 | |
| | 500 | |
| | 500 | |
| | 500 | |
| | 501 | |
| | 502 | |
| | 502 | |
| | 502 | |
| | 507 | |
| | 508 | |
| | 508 | |
| | 508 | |
| | 509 | |
| | 510 | |
| | 510 | |
| | 510 | |
| | 512 | |
| | 513 | |
| | 513 | |
| | 513 | |
| | 514 | |
| | 515 | |
| | 515 | |
| | 515 | |
| | 518 | |
| | 519 | |
| | 519 | |
| | 519 | |
| | 525 | |
| | 526 | |
| | 526 | |
| | 526 | |
| | 527 | |
| | 528 | |
| | 528 | |
| | 528 | |
| | 530 | |
| | 531 | |
| | 531 | |
| | 531 | |
| | 532 | |
| | 533 | |
| | 533 | |
| | 533 | |
| | 534 | |
| | 535 | |
| | 535 | |
| | 535 | |
| | 538 | |
| | 539 | |
| | 539 | |
| | 539 | |
| | 541 | |
| | 542 | |
| | 542 | |
| | 542 | |
| | 546 | |
| | 547 | |
| | 547 | |
| | 547 | |
| | 548 | |
| APPENDIX A. Ruby Primer and Review for Developers |
| | 549 | |
| | 549 | |
| | 549 | |
| The Ruby Interpreter and Running Ruby Code |
| | 551 | |
| | 553 | |
| Expressions, Logic, and Flow Control |
| | 553 | |
| | 553 | |
| | 554 | |
| | 555 | |
| | 557 | |
| | 561 | |
| | 562 | |
| | 563 | |
| | 565 | |
| | 567 | |
| | 568 | |
| | 569 | |
| | 569 | |
| | 569 | |
| | 572 | |
| | 574 | |
| Hashes (Associative Arrays) |
| | 574 | |
| | 576 | |
| | 576 | |
| | 577 | |
| | 577 | |
| | 578 | |
| | 579 | |
| | 579 | |
| | 580 | |
| APPENDIX B. Ruby Reference |
| | 581 | |
| Useful Classes and Methods |
| | 581 | |
| | 581 | |
| | 583 | |
| | 584 | |
| | 585 | |
| | 585 | |
| | 586 | |
| | 586 | |
| | 587 | |
| | 588 | |
| Regular Expression Syntax |
| | 590 | |
| Regular Expression Options |
| | 591 | |
| Special Characters and Formations |
| | 591 | |
| Character and Sub-Expression Suffixes |
| | 592 | |
| | 592 | |
| | 596 | |
| | 597 | |
| APPENDIX C. Useful Resources |
| | 601 | |
| | 601 | |
| | 601 | |
| | 602 | |
| | 603 | |
| Aggregators and Community Blogs |
| | 603 | |
| | 604 | |
| | 604 | |
| | 605 | |
| | 606 | |
| | 607 | |
| | 607 | |
| | 608 | |
| | 609 | |
| | 610 | |
| Index | | 611 | |