Ruby Phrasebook
  • Ruby Phrasebook
  • Ruby Phrasebook

Ruby Phrasebook

by Jason D. Clinton

Ruby Phrasebook

Jason Clinton

Essential Code and Commands

Ruby Phrasebook gives you the code you need to quickly and effectively work with Ruby, one of the fastest-growing languages in the world thanks to popular new Ruby technologies like Ruby on Rails.

Concise and Accessible

Easy to carry and easy to use—lets you ditch all those

…  See more details below


Ruby Phrasebook

Jason Clinton

Essential Code and Commands

Ruby Phrasebook gives you the code you need to quickly and effectively work with Ruby, one of the fastest-growing languages in the world thanks to popular new Ruby technologies like Ruby on Rails.

Concise and Accessible

Easy to carry and easy to use—lets you ditch all those bulky books for one portable pocket guide

Flexible and Functional

Packed with more than 100 customizable code snippets—so you can readily code functional Ruby in just about any situation

Jason Clinton uses Ruby daily in system administration and development for Advanced Clustering Technologies, a Linux Beowulf cluster integrator. He has been working in the computer industry for more than a decade and is actively involved in the Kansas City Ruby Users Group (KCRUG), serving as administrator of the group’s web site and mailing list.

Register your book at for convenient access to downloads, updates, and corrections as they become available.

Programming / Ruby

Read More

Product Details

Publication date:
Developer's Library Series
Sales rank:
Product dimensions:
4.40(w) x 6.90(h) x 0.50(d)

Read an Excerpt


You can find some great Ruby books on the market. If you are new to Ruby, a friend or someone on the Internet has probably already listed some favorite Ruby books—and you should buy those books. But every book has its niche: Each attempts to appeal to a certain need of a programmer.

It is my belief that the best thing this book can do for you is show you the code. I promise to keep the chat to a minimum, to focus instead on the quality and quantity of actual Ruby code. I'll also keep as much useful information in as tight a space as is possible.

Unlike any other book on the market at the time of this writing, this book is intended to be a (laptop-bag) "pocket-size" resource that enables you to quickly look up a topic and find examples of practical Ruby code—a topical quick reference, if you will. In each of the topics covered, I try to provide as thorough an approach to each task as the size allows for; there's not as much room for coverage of topical solutions as there is in much larger books with similar goals, such as The Ruby Way, 2nd Edition (Sams, 2006), by Hal Fulton. Because of this, other issues that are often given equal priority are relegated to second. For instance, this is not a tutorial; the code samples have some explanation, but I assume that you have a passing familiarity with the language. Also, when possible, I try to point out issues related to security and performance, but I make no claim that these are my highest priority.

I hope that you find this book a useful tool that you keep next to your keyboard whenever you are phrase-mongering inRuby.How to Use This Book

I have not intended for this book to be read cover to cover. Instead, you should place your bookmark at the Table of Contents so you can open the book, find the topic you are programming on at the moment, and go immediately to a description of all the issues you might run into.

The content in the book is arranged by topic instead of Ruby class. The benefit is that you can go to one place in this book instead of four or five areas in Ruby's own documentation. (Not that there's anything wrong with Ruby's documentation. It's just that sometimes you are working with several classes at a time and, because Ruby's docs are arranged by class, you have to jump around a lot.)Conventions

Phrases throughout the book are put in dark gray boxes at the beginning of every topic.

Phrases look like this.

Code snippets that appear in normal text are in italics. All other code blocks, samples, and output appear as follows:

# code sample boxes.

Parentheses are optional in Ruby in some cases—the rule is: you must have parentheses in your method call if you are calling another function in your list of parameters, or passing a literal code block to the method. In all other cases, parentheses are optional. Personally, I'm a sucker for consistency but one of the indisputable strengths of Ruby is the flexibility of the syntax.

In an attempt to have consistency between this book and others, I will (reluctantly) use .class_method() to refer to class methods, ::class_variable to refer to class variables, #method() to refer to instance methods, and finally #var to refer to instance variables. When referring to variables and methods which are members of the same class, I'll use the appropriate @variable and @@class_varriable.

I know that some people might find these two rules annoying—especially those coming from languages that use the '::' and '.' notation everywhere. In all practicality, you will never be so consistent—and rightfully so. One of Ruby's strengths is that there is a ton of flexibility. In fact, this flexibility has helped make Ruby on Rails so popular. This allowed the creators of Rails to make what appears to be a domain-specific language (a language well-suited for a specific kind of work) for web development. But really, all that is going on is a variation on Ruby syntax. And this is one of the many reasons that Ruby is more suitable for a given problem than, say, Python. Python's rigidity ("there should be one—and preferably only one—obvious way to do it") doesn't lend itself to DSL, so the programmers in that language are forced to use other means (which might or might not turn out to be unpleasant).

I always use single quotes (') in Ruby code unless I actually want to make use of the double-quote (")features (interpolation and substitution).

I always put the result of the evaluation of the statement (or block) on the next line with a proceeding #=>, similar to what you would find if you were using irb or browsing Ruby's documentation.

Comments on executable lines of code start with # and are in italics to the end of the comment. Comments on #=> lines are in parentheses and are in italics.Acknowledgments

Without the Pragmatic Programmers' freely available 1st Edition of Programming Ruby, I would have never discovered the wonderful world of Ruby. The Pickaxe books and the great Ruby community are what make projects like this one possible.

Thanks to my loving partner, Brandon S. Ward, for his infinite patience while working on this book.Reporting Errata

Readers will almost certainly find topics that they wish were covered which we were overlooked when planning this book. I encourage you to please contact us and let us know what you would like to see included in later editions. Criticisms are also welcome. Contact information can be found in the front-matter of this book.

© Copyright Pearson Education. All rights reserved.

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >