Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 326 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
326
Dung lượng
3,09 MB
Nội dung
this print for content only—size & color not accurate spine = 0.7655" 328 page count Books for professionals By professionals ® PracticalRuby Projects: Ideas for the Eclectic Programmer Dear Reader, You’ve learned the basics of Ruby, and you’re ready to move on to the next level— trying out advanced techniques, mastering best practices, and exploring Ruby’s full potential. With this book you’ll learn by experience while you tackle an exciting series of varied but always practical programming projects. What is an eclectic programmer, you ask? He or she is an inquisitive thinker who likes to play around with new concepts, a person who is project-oriented and enjoys coding, a person who doesn’t mind some technical depth folded in with creative excursions, and a person who is always looking for fresh ideas. This book is a little different from other computer books. It is meant to be entertaining, exciting, and intellectually challenging. Inside you’ll find a collec- tion of diverse projects, ranging from the creative to the practical, written as a nod to all the great Rubyists I’ve been privileged to know. Each chapter dives into new topics and approaches meant to exercise your programming muscles. You’ll start by building a cross-platform music environment, progress to drawing animations using scalable vector graphics, and then move on to prac- tical problem solving using simulation. In addition, you’ll implement your own turn-based strategy game and build a Mac-native RubyCocoa interface to it. Next, you’ll revisit your simulation with the assistance of biologically inspired genetic algorithms. And, in the last two projects, you’ll implement your very own Lisp interpreter and explore the theory and practice behind parsers. This book is about projects because Ruby culture is a project culture. These ideas are meant to be instructional, enjoyable, and useful as stepping stones. Start coding, and be sure to let me know where it takes you! Topher Cyll US $44.99 Shelve in Ruby User level: Intermediate–Advanced Cyll PracticalRuby Projects The eXperT’s Voice ® in open source PracticalRuby Projects Ideas for the Eclectic Programmer cyan MaGenTa yelloW Black panTone 123 c Topher Cyll Companion eBook Available THE APRESS ROADMAP PracticalRuby for System Administration Pro Active RecordPractical Ruby Gems Practical JRuby on Rails Web 2.0 Projects PracticalRuby Projects Beginning Ruby Beginning Rails Practical Rails Projects www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN-13: 978-1-59059-911-2 ISBN-10: 1-59059-911-X 9 781590 599112 5 4 4 9 9 Learn advanced programming techniques and explore Ruby’s full potential through a varied series of exciting projects [...]... 3:54 PM Page 4 CHAPTER 1 ■ INTRODUCTION You’ll also want RubyGems installed RubyGems is the convenient system for managing Ruby libraries Depending on how you installed Ruby, you may or may not have RubyGems already installed You can easily check by typing the following into irb: require 'rubygems' ■ irb is the interactive Ruby environment Type some Ruby in and see the result You’ll probably need to Tip... you already know about Ruby s strengths The Language You know that Ruby s blocks are a joy to use You know how Ruby s programmer-oriented core API can make programming feel effortless Despite what the popular press sometimes says, Ruby isn’t the final word in programming languages But Ruby holds a unique position in the current landscape Borrowing from the Smalltalk tradition, Ruby brings a new level... directly into C libraries from Ruby! The library is called Ruby DL, and it comes with Ruby right out of the box ■ Caution There is a new version of Ruby DL in progress Version 2 will fix some of the problems associated with the original However, the code in this chapter is written for version 1 (the version that is bundled with the Ruby 1.8 series) You’re now going to build Ruby MIDI bindings for all three... Interoperating with Ruby 253 Opening a Window to Ruby 254 Sending Messages 254 Making Lisp Lambda Work in Ruby 255 Summary 256 ■ CHAPTER 9 Parsing in Ruby 261 Parsing with Ruby ... and started turning to Ruby That’s when I went to my first Portland Ruby Brigade (PDX.rb) meeting Which brings me to Ruby s second strength: its community Now, every language community has its own flavor and culture Maybe it is just because it’s a fresh language with the right set of features, but the programmers you meet in the Ruby track at conferences, the hackers at your local Ruby Brigade, and the... independent concepts Getting Set Up You’re obviously going to need Ruby installed! This book was written using the Ruby 1.8 series The code was tested on Ruby 1.8.5, but it should work on any 1.8 release Time will tell how well it bridges the gap to 2.0 (I’m optimistic.) Ruby is available for most major operating systems from its web site: www .ruby- lang.org/ There are detailed instructions for each platform,... programmers of the Portland Ruby Brigade for showing me the curious excitement of Ruby Additional thanks to my family, friends, and roommates for cutting me a year’s worth of slack I owe you! xix 911Xfm.qxd 11/9/07 8:08 AM Page xx 911Xch01.qxd 10/29/07 3:54 PM CHAPTER Page 1 1 Introduction T his book is titled PracticalRuby Projects And let me start by saying that the projects are practical But they might... turns Ruby loose on a new interesting problem or project They range from creative endeavors to investigative simulations to the exploration of computer programming languages themselves Ruby is a programming language, but it’s also a tool to create, understand, and entertain This book is all about Ruby Why Ruby? Since this book was written with the assumption that you have a basic knowledge of Ruby, ... system libraries from Ruby These libraries are typically written in C, and getting Ruby to talk to them can be tricky Traditionally, the “bindings” between a high-level language like Ruby (which is implemented in C) and lower-level C libraries are written in C Using this strategy, you’d write a C file that interfaced and linked with the MIDI libraries This C file would also use the Ruby C API to expose... administration Combined with the Ruby on Rails web development buzz, Ruby s future is promising, particularly with progress toward a faster runtime environment 1 911Xch01.qxd 2 10/29/07 3:54 PM Page 2 CHAPTER 1 ■ INTRODUCTION The Community I first encountered Ruby in 2004 while working at Intel in Hillsboro, Oregon The approved higher-level languages were Perl and Ruby I was a Python programmer at . APRESS ROADMAP Practical Ruby for System Administration Pro Active RecordPractical Ruby Gems Practical JRuby on Rails Web 2.0 Projects Practical Ruby Projects Beginning Ruby Beginning Rails Practical. you! Topher Cyll US $44.99 Shelve in Ruby User level: Intermediate–Advanced Cyll Practical Ruby Projects The eXperT’s Voice ® in open source Practical Ruby Projects Ideas for the Eclectic Programmer . count Books for professionals By professionals ® Practical Ruby Projects: Ideas for the Eclectic Programmer Dear Reader, You’ve learned the basics of Ruby, and you’re ready to move on to the next