Ruby by Example

Concepts and Code
by Kevin C. Baird

June 2007, 312 pp.
ISBN: 978-1-59327-148-0

This book is currently out of stock, but the ebook is still available

View a sample chapter, Chapter 6: Functionalism with Blocks and Procs

Download Ruby by Example's source code files here: .zip  .bz2

Download the Ruby by Example Rails Application here: .zip  .bz2

There may be no better way to learn how to program than by dissecting real, representative examples written in your language of choice. Ruby by Example analyzes a series of Ruby scripts, examining how the code works, explaining the concepts it illustrates, and showing how to modify it to suit your needs. Baird's examples demonstrate key features of the language (such as inheritance, encapsulation, higher-order functions, and recursion), while simultaneously solving difficult problems (such as validating XML, creating a bilingual program, and creating command-line interfaces). Each chapter builds upon the previous, and each key concept is highlighted in the margin to make it easier for you to navigate the book.

You'll learn how to:

  • Use the interactive Ruby shell (irb) to learn key features of the language
  • Extend Ruby using RubyGems, the Ruby package manager
  • Create numerical utilities, as well as utilities that process and analyze HTML/XML
  • Implement purely functional and metaprogramming techniques to save time and effort
  • Optimize, profile, and test your code to make sure that it not only does its job, but does it well
  • Create web applications using Rails

Ruby is the fastest growing programming language today, and for good reason: Its elegant syntax and readable code make for prolific and happy programmers. But it can be difficult to understand and implement without a little help. Ruby by Example shows you how to take advantage of Ruby as you explore Ruby's fundamental concepts in action.


About the Author

Kevin C. Baird received his Ph.D. from the State University of New York at Buffalo. He originally wrote his dissertation in Python but rewrote the project after discovering Ruby, and he hasn't looked back since. He has presented at RubyConf and written articles for Linux Journal, Music & Computers magazine, and the New Interfaces for Musical Expression conference proceedings.


Table of Contents

Introduction: What is Ruby?
Chapter 1: Interactive Ruby and the Ruby Environment
Chapter 2: Amusements and Simple Utilities
Chapter 3: Programmer Utilities
Chapter 4: Text Manipulation
Chapter 5: Number Utilities
Chapter 6: Functionalism with Blocks and Procs
Chapter 7: Using, Optimizing, and Testing Functional Techniques
Chapter 8: HTML and XML Tools
Chapter 9: More Complex Utilities and Tricks Part I
Chapter 10: More Complex Utilities and Tricks Part II
Chapter 11: CGI and the Web
Chapter12: RubyGems and Rails Preparation
Chapter 13: A Simple Rails Project
Appendix: How Does Ruby Compare to Other Languages?
Index

View the detailed Table of Contents (PDF).

View the Index (PDF).

(top)

Reviews

"All told, [Ruby by Example] is yet another great book from No Starch Press. I enjoyed reading it, and I sharpened my Ruby skills along the way."
—LinuxWorld (Read More)

"Regardless of your leanings or preferences, if you believe learning Ruby is in your future, pick up a copy of this book. You'll start acquiring hands-on experience from the very beginning."
—Linux Magazine

Kevin Baird, author of Ruby by Example, talks with Dr. Dobb's Journal about the Ruby language and its place among other high-level scripting languages.
Click here to listen to the podcast.

"The real subject matter [of Ruby by Example] is an introduction to Ruby from a functional programming perspective. This is a huge bonus. There are many books about Ruby that emphasize its OO features, but too few with a clear, succinct, powerful approach to functional programming."
—Giles Bowkett (Read More)

"The book is aimed at being immediately accessible to all levels of Ruby programmers, however it has a very interesting slant towards the often overlooked functional programming strengths of Ruby. If you love your scripting languages served with a burst of lambdas and proc objects, or you're a fan of Haskell and Lisp, this book is for you."
—LinuxSecurity.com (Read More)

"If you're looking for a good book to help build your Ruby muscles, this is a good one to grab."
—Pat Eyler (Read More)

"There is something to be said for Baird's 'let's dive in and try it out' approach. If you want to get quickly started with some hands-on Ruby coding, Ruby By Example is the way to go."
—bitwise magazine (Read More)

"This book is an excellent resource for improving one's understanding of Ruby and using it more effectively."
—Major Keary, Book News

"If you've already got some programming experience under your belt and are searching for a book that'll get you up to speed with Ruby very quickly, I strongly recommend Ruby by Example (written by Kevin Baird and published by No Starch Press, whose books on coding have impressed me)."
—Global Nerdy (Read More)

(top)

Updates

(show updates)(top)