Table Of Content1 YEAR UPGRADE
BUYER PROTECTION PLAN
R U BY
Developer’s
Guide
Everything You Need to Develop and Deliver Ruby Applications
•Complete Case Studies with Ready-to-Run Source Code and Full
Explanations
• Hundreds of Developing & Deploying Sidebars,Ruby FAQs,and Ruby
Sample Applications
• Complete Coverage of Ruby GUI Toolkits:Tk,GTK+,FOX,SWin/Vruby
Extensions,and Others
Robert Feldt
Lyle Johnson
Michael Neumann
Technical Editor
183_Ruby_FM.qxd 1/7/02 4:04 PM Page i
s o l u t i o n s @ s y n g r e s s . c o m
With more than 1,500,000 copies of our MCSE, MCSD, CompTIA, and Cisco
study guides in print, we continue to look for ways we can better serve the
information needs of our readers. One way we do that is by listening.
Readers like yourself have been telling us they want an Internet-based ser-
vice that would extend and enhance the value of our books. Based on
reader feedback and our own strategic plan, we have created a Web site
that we hope will exceed your expectations.
[email protected] is an interactive treasure trove of useful infor-
mation focusing on our book topics and related technologies. The site
offers the following features:
(cid:2) One-year warranty against content obsolescence due to vendor
product upgrades. You can access online updates for any affected
chapters.
(cid:2) “Ask the Author” customer query forms that enable you to post
questions to our authors and editors.
(cid:2) Exclusive monthly mailings in which our experts provide answers to
reader queries and clear explanations of complex material.
(cid:2) Regularly updated links to sites specially selected by our editors for
readers desiring additional reliable information on key topics.
Best of all, the book you’re now holding is your key to this amazing site.
Just go to www.syngress.com/solutions, and keep this book handy when
you register to verify your purchase.
Thank you for giving us the opportunity to serve your needs. And be sure
to let us know if there’s anything else we can do to help you get the
maximum value from your investment. We’re listening.
www.syngress.com/solutions
183_Ruby_FM.qxd 1/7/02 4:04 PM Page ii
183_Ruby_FM.qxd 1/7/02 4:04 PM Page iii
1 YEAR UPGRADE
BUYER PROTECTION PLAN
R u b y
D e v e l o p e r ’s G u i d e
Robert Feldt
Lyle Johnson
Michael Neumann
Technical Editor
183_Ruby_FM.qxd 1/7/02 4:04 PM Page iv
Syngress Publishing,Inc.,the author(s),and any person or firm involved in the writing,editing,or
production (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be
obtained from the Work.
There is no guarantee of any kind,expressed or implied,regarding the Work or its contents.The Work is
sold AS IS and WITHOUT WARRANTY.You may have other legal rights,which vary from state to state.
In no event will Makers be liable to you for damages,including any loss of profits,lost savings,or other
incidental or consequential damages arising out from the Work or its contents.Because some states do not
allow the exclusion or limitation of liability for consequential or incidental damages,the above limitation
may not apply to you.
You should always use reasonable care,including backup and other appropriate precautions,when working
with computers,networks,data,and files.
Syngress Media®,Syngress®,“Career Advancement Through Skill Enhancement®,”and “Ask the Author
UPDATE®,”are registered trademarks of Syngress Publishing,Inc.“Mission Critical™,”“Hack Proofing™,”
and “The Only Way to Stop a Hacker is to Think Like One™”are trademarks of Syngress Publishing,Inc.
Brands and product names mentioned in this book are trademarks or service marks of their respective
companies.
KEY SERIAL NUMBER
001 UJG4TFR2T5
002 AKJ7T4MAS4
003 VMERF3854N
004 SGD34BK9HN
005 85DFMU6N7H
006 NFG438GEM4
007 BAQ2HTR46T
008 CV5TR56KMR
009 83N5M4BT6Y
010 GT67FRWFEC
PUBLISHED BY
Syngress Publishing,Inc.
800 Hingham Street
Rockland,MA 02370
The Ruby Developer’s Guide
Copyright © 2002 by Syngress Publishing,Inc.All rights reserved.Printed in the United States of America.
Except as permitted under the Copyright Act of 1976,no part of this publication may be reproduced or
distributed in any form or by any means,or stored in a database or retrieval system,without the prior
written permission of the publisher,with the exception that the program listings may be entered,stored,
and executed in a computer system,but they may not be reproduced for publication.
Printed in the United States of America
1 2 3 4 5 6 7 8 9 0
ISBN: 1-928994-64-4
Technical Editor:Michael Neumann Cover Designer:Michael Kavish
Acquisitions Editor:Catherine B.Nolan Page Layout and Art by:Reuben Kantor and Shannon Tozier
Developmental Editor:Kate Glennon Copy Editor:Jesse Corbeil
Indexer:Robert Saigh
Distributed by Publishers Group West in the United States and Jaguar Book Group in Canada.
183_Ruby_FM.qxd 1/7/02 4:04 PM Page v
Acknowledgments
We would like to acknowledge the following people for their kindness and support
in making this book possible.
Richard Kristof and Duncan Anderson of Global Knowledge,for their generous
access to the IT industry’s best courses,instructors,and training facilities.
Ralph Troupe,Rhonda St.John,and the team at Callisma for their invaluable insight
into the challenges of designing,deploying and supporting world-class enterprise
networks.
Karen Cross,Lance Tilford,Meaghan Cunningham,Kim Wylie,Harry Kirchner,
Kevin Votel,Kent Anderson,and Frida Yara of Publishers Group West for sharing
their incredible marketing experience and expertise.
Mary Ging,Caroline Hird,Simon Beale,Caroline Wheeler,Victoria Fuller,Jonathan
Bunkell,and Klaus Beran of Harcourt International for making certain that our
vision remains worldwide in scope.
Annabel Dent of Harcourt Australia for all her help.
David Buckland,Wendi Wong,Marie Chieng,Lucy Chong,Leslie Lim,Audrey Gan,
and Joseph Chan of Transquest Publishers for the enthusiasm with which they receive
our books.
Kwon Sung June at Acorn Publishing for his support.
Ethan Atkin at Cranbury International for his help in expanding the Syngress
program.
Jackie Gross,Gayle Vocey,Alexia Penny,Anik Robitaille,Craig Siddall,Darlene
Morrow,Iolanda Miller,Jane Mackay,and Marie Skelly at Jackie Gross & Associates
for all their help and enthusiasm representing our product in Canada.
Lois Fraser,Connie McMenemy,and the rest of the great folks at Jaguar Book Group
for their help with distribution of Syngress books in Canada.
vv
183_Ruby_FM.qxd 1/7/02 4:04 PM Page vi
Technical Editor’s
Acknowledgements
I’d like to thank the Syngress staff for their support,and John Small,who
encouraged me in overseeing the writing of this book.I’d like to thank
Matz for creating such a wonderful language;Dave and Andy for two
really great books about programming in general,and Ruby;Kentaro
Goto for his tutorial that directed me three years ago to Ruby;and
Hiroshi Nakamura for many valuable comments and explanations about
SOAP4R.Finally,thank you to the team of Merlin.zwo for being patient
with me,as well as to the whole Ruby community for letting me partici-
pate in such a great development.
vi
183_Ruby_FM.qxd 1/7/02 4:04 PM Page vii
Contributors
Jason Wong is the Chief Executive Officer of ionami design,a Web
development and design firm headquartered in Berkeley,CA.His respon-
sibilities include developing and maintaining client relationships,project
management,application development and support,and operations man-
agement.Previously,he managed all aspects of 3dfxgamers.com,the 3dfx
interactive community Web site.Jason holds a bachelor’s degree from the
University of California at Berkeley.He would like to thank Joyce,Ted
and Tim,and his parents for all their support.
Lyle Johnson is a Software Team Leader at ResGen,Invitrogen
Corporation in Huntsville,AL.Prior to his employment at ResGen,Lyle
served as Group Leader for Graphical User Interface Development at
CFD Research Corporation.Lyle has worked primarily in commercial
software development for computational fluid dynamics and bioinfor-
matics applications,but has also managed and contributed to a number of
open-source software projects.
Lyle holds a bachelor’s degree in Aerospace Engineering from Auburn
University and a master’s of Science degree in Aerospace Engineering
from the Georgia Institute of Technology.He currently lives in Madison,
AL with his wife,Denise.
Jonothon Ortiz is Vice President of Xnext,Inc.in Winter Haven,FL.
Xnext,Inc.is a small,privately owned company that develops Web sites
and applications for prestigious companies such as the New York Times
Company.Jonothon is the head of the programming department and
works together with the CEO on all company projects to ensure the best
possible solution.Jonothon lives with his wife,Carla,in Lakeland,FL.
Robert Feldt is a Software Engineering Researcher at Chalmers
University of Technology in Gothenburg,Sweden.His professional
interest is in how to produce robust,reliable software.Robert’s research
vii
183_Ruby_FM.qxd 1/7/02 4:04 PM Page viii
focuses on what can be learned from applying the complex but robust
systems found in nature to tools and methods for developing and testing
software.Robert also teaches courses on software engineering to students
in the Computer Science and Computer Engineering programs at
Chalmers University.
Robert holds a master’s degree from Chalmers University and is a
member of the IEEE.He has previously worked as a consultant software
engineer.He programs mostly in C,Haskell,and Ruby and uses Ruby
frequently in his research since its dynamic nature allows him to easily test
new ideas.He is working on a number of larger Ruby projects,including
the Rockit compiler construction toolkit and the RubyVM project,to
build a set of plug-and-play components for assembling Ruby virtual
machines.
Robert currently resides in Gothenburg,Sweden with his wife,
Mirjana,and daughter,Ebba.He wants to acknowledge them for their
support and love.
Stephen Legrand (Ph.D.) has both an academic and commercial back-
ground.He was a post-doctoral fellow at MIT and has lectured both
mathematical and computer science related subjects at the university level.
He has taught graduate and undergraduate courses in such diverse areas as
assembly language,automata theory,computability,discrete mathematics,
computer graphics,and in mathematical subjects such as differential equa-
tions,advanced calculus,financial mathematics,and model theory.In addi-
tion,Stephen has over 10 years of software development expertise in such
areas as fixed income derivatives,interest rate modeling,artificial intelli-
gence,and telecommunications.He has authored computer graphics
engines,computer chess games,option pricing engines,cellular propaga-
tion models,and workflow management systems.He is currently con-
sulting on the IRROS project and on J2EE-related technologies in the
Washington,DC area.
viii
183_Ruby_FM.qxd 1/7/02 4:04 PM Page ix
Technical Editor and Contributor
Michael Neumann is a Database and Software Developer for
Merlin.zwo InfoDesign GmbH in Germany (near Stuttgart).He is also
studying computer science at the University of Karlsruhe.Merlin.zwo
develops large-scale database applications based on Oracle products.
With more than 10 years of experience in software development,
Michael has specialized in many different domains,from system-near
programming,administration of Unix systems,and database develop-
ment with several RDBMSs,to OOA/OOD techniques,and design and
implementation of distributed and parallel applications.One of his
greatest interests lies is the design principles of programming languages.
Before he was employed at Merlin.zwo,he was a Database/Web
Developer and Principal of Page-Store.
ix