1111222371 {d254d1f3} ruby programming ford 2010 10 22

443 986 0
1111222371 {d254d1f3} ruby programming ford 2010 10 22

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1019763_FM_VOL-I.qxp 9/17/07 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 S 50 R 51 4:22 PM Page viii This page was intentionally left blank 1st Pass Pages RUBY PROGRAMMING JERRY LEE FORD, JR Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd i 03/09/10 10:35 PM Ruby Programming Jerry Lee Ford, Jr Executive Editor: Marie Lee Acquisitions Editor: Brandi Shailer Senior Product Manager: Alyssa Pratt Development Editor: Kent Williams Content Project Manager: Lisa Weidenfeld Editorial Assistant: Jacqueline Lacaire Associate Marketing Manager: Shanna Shelton Cover image credit: ©istockphoto/ jennyking Copyeditor: Suzanne Ciccone © 2011 Course Technology, Cengage Learning ALL RIGHTS RESERVED No part of this work covered by the copyright herein may be reproduced, transmitted, stored or used in any form or by any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, information networks, or information storage and retrieval systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the publisher For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706 For permission to use material from this text or product, submit all requests online at www.cengage.com/permissions Further permissions questions can be emailed to permissionrequest@cengage.com Proofreader: Kim Kosmatka Indexer: Sharon Hilgenberg Art Director: Faith Brosnan Text Designer: Shawn Gersberger Cover Designer: Cabbage Design Company Compositor: Integra Library of Congress Control Number: 2010935900 ISBN-13: 978-1-111-22237-6 ISBN-10: 1-111-22237-1 Course Technology 20 Channel Center Street Boston, MA 02210 Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan Locate your local office at: www.cengage.com/global Cengage Learning products are represented in Canada by Nelson Education, Ltd To learn more about Course Technology, visit www.cengage.com/ coursetechnology To learn more about Cengage Learning, visit www.cengage.com Purchase any of our products at your local college store or at our preferred online store www.cengagebrain.com Some of the product names and company names used in this book have been used for identification purposes only and may be trademarks or registered trademarks of their respective manufacturers and sellers Any fictional data related to persons or companies or URLs used throughout this book is intended for instructional purposes only At the time this book was printed, any such data was fictional and not belonging to any real persons or companies Course Technology, a part of Cengage Learning, reserves the right to revise this publication and make changes from time to time in its content without notice The programs in this book are for instructional purposes only They have been tested with care, but are not guaranteed for any particular intent beyond educational purposes The author and the publisher not offer any warranties or representations, nor they accept any liabilities with respect to the programs Printed in the United States of America 15 14 13 12 11 10 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd ii 03/09/10 10:35 PM This is an electronic version of the print textbook Due to electronic rights restrictions, some third party content may be suppressed Editorial review has deemed that any suppressed content does not materially affect the overall learning experience The publisher reserves the right to remove content from this title at any time if subsequent rights restrictions require it For valuable information on pricing, previous editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for materials in your areas of interest Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it 1019763_FM_VOL-I.qxp 9/17/07 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 S 50 R 51 4:22 PM Page viii This page was intentionally left blank 1st Pass Pages Brief Contents iii Pref ace xii CHAPTER Ru by B as ic s CHAPTER In t er act in g wi th R uby CHAPTER Wo r k in g wi th Stri ngs, Obj ects, an d Var iabl es 77 CHAPTER Im plem en ti ng Condi ti onal Logi c 114 CHAPTER Wo r k in g wi th Loops 146 CHAPTER Wo r k in g wi th Col l ecti ons of Data CHAPTER Wo r k in g wi th R egul ar Ex pressi ons 221 CHAPTER Object -Or i ented Programmi ng 257 CHAPTER F ile an d F ol der Admi ni strati on 294 CHAPTER 10 Debu g g in g 331 CHAPTER 11 Ru by o n Rai l s Web Dev el opment 368 41 181 Glo s s ar y 401 In dex 407 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd iii 03/09/10 10:35 PM Contents iv Pref ace CHAPTER xii Ru by B as ics Project Preview: The Ruby Joke Game A Brief History of Computers and Computer Programming The Mechanized Era The First Generation The Second Generation The Third Generation The Fourth Generation The Fifth Generation 1990 and Beyond Introducing Ruby Ruby Is Simple Yet Powerful Ruby Is Object Oriented Ruby Is Extremely Flexible Ruby Exists in Many Different Environments Getting Ready to Work with Ruby Determining Whether Ruby Is Already Installed Installing or Upgrading Ruby Working with Ruby Working at the Command Prompt IRB—Interactive Ruby fxri–Interactive Ruby Help and Console Developing Ruby Programs Creating Ruby Programs on Microsoft Windows Creating Ruby Programs on Mac OS X Creating Ruby Programs on Linux and UNIX Using a Cross-Platform Ruby Editor Creating Your First Ruby Program Running Your Ruby Program Back to the Ruby Joke Game Designing the Game Running Your New Ruby Program Game 10 11 13 14 14 15 15 17 21 21 21 23 24 24 24 24 24 25 26 27 27 32 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd iv 03/09/10 10:35 PM CONTENTS Summing Up Comprehension Check Reinforcement Exercises Discovery Projects CHAPTER In t er act in g wi th R uby 35 36 38 39 41 Project Preview: The Ruby Tall Tale Game Getting to Know IRB Starting an IRB Session Working with Multiple IRB Sessions Accessing IRB Online Working with IRB Executing Ruby Statements Following Ruby’s Syntax Rules Executing Incomplete Statements Using IRB to Test Ruby Scripts Using IRB to Perform Mathematical Calculations Using IRB as a Calculator Accessing Methods Stored in the Math Module Operator Precedence Overriding Operator Precedence Integers Versus Floating-Point Numbers Accessing Ruby Documentation Back to the Ruby Tall Tale Game Designing the Ruby Tall Tale Game Running Your New Ruby Script Game Summing Up Comprehension Check Reinforcement Exercises Discovery Projects CHAPTER v 42 46 46 48 48 49 49 50 51 51 53 53 54 54 55 56 56 59 60 65 70 71 74 75 Wo r k in g wi th Stri ngs, Obj ects, an d Var iabl es 77 Project Preview: The Ruby Virtual Crazy Creating and Formatting Text Strings Modifying Text String Format String Interpolation Manipulating String Contents Concatenating Text Strings Multiplying Text Strings Comparing Text Strings Creating Multiline Text Strings 8-Ball Game 78 81 82 83 83 84 84 85 85 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd v 03/09/10 10:35 PM CONTENTS Working with String Class Methods Object-Oriented Programming Defining a New Class Defining Class Properties Instantiating and Interacting with New Objects Defining Class Methods Inheritance Converting from One Class to Another Implicit Class Conversion Explicit Class Conversion Storing and Retrieving Data Naming Variables Variable Assignments Variable Scope Storing Data That Does Not Change Back to the Ruby Virtual Crazy 8-Ball Game Designing the Game Running Your New Ruby Script Game Summing Up Comprehension Check Reinforcement Exercises Discovery Projects vi CHAPTER 87 88 88 89 89 90 91 92 93 93 95 96 96 97 98 100 100 107 107 108 111 112 Im plem en t in g Condi ti onal Logi c 114 Project Preview: The Ruby Typing Challenge Game Using Conditional Logic to Create Adaptive Scripts Performing Alternative Types of Comparisons Conditional Logic Modifiers The if Modifier The unless Modifier Working with if and unless Expressions Creating if Expressions Replacing if Modifiers with if Expressions Creating unless Expressions Using case Blocks to Analyze Data Using the Ternary Operator Nesting Conditional Statements Combining and Negating Logical Comparison Operations Back to the Ruby Typing Challenge Game Designing the Game Running Your New Ruby Script Game 115 119 121 122 122 122 123 123 124 126 127 129 129 130 132 132 140 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_fm.indd vi 03/09/10 10:35 PM Index metacharacter, 232 /…/ operator, 228 + character, 232–233, 233 => marker, 344 $ metacharacter, 232 * metacharacter, 232–233 ? metacharacter, 232 * method, 84 + method, 84, 267, 275 arrays, 267–268 operator, 338 || operator, 130, 131 #!/usr/bin/ruby -w command, 26 #!/usr/local/bin/ruby -w command, 26 A abstraction, 262 acos() method, 54 Action Controller, 373 Action Mailer, 373 Active Record library, 372–373 Active Resource, 373 Active State website, 24 Active Support, 373 Active View library, 373 ADA, 10 adaptive scripts creation, 119–121 add method, 275–276 Addition (+) operator, 53, 188 Add_Stuff method, 98 ALGOL, alternative actions, 124–125 alternative conditions, checking, 125 alternative course of action, 126 Analytical Engine, 5–6 analyze_results method, 281, 282–283 and operator, 130 answer variable, 62, 94, 106, 162, 169, 284, 319, 357 app/controller folder, 382 app folder, 382 app/helpers folder, 382 app/models folder, 382 app/views folder, 382 app/views/home folder, 386 app/views/layouts folder, 382 appending data to end of text files, 308 Applications folder, 16 arc cosine, 54 arguments, 23, 47, 90 arithmetic assignment operator (+=), 97 Array class, 156–157, 189, 190– 195, 245, 274, 310 Array object, 187 arrays, 153, 186 () operator, 122, 123 greater than or equal to (>=) operator, 122 Greeting class, 271, 272 greeting property, 103 Greeting.txt file, 304 gsub method, 235, 246 G H Game class, 205–206, 208–210, 212, 238–240, 242–243, 246–247, 279, 283–284, 286, 313, 315, 319, 321, 349–350, 352, 354–357, 359 game instructions text strings, 135 gameOver variable, 106, 107 $gem -v command, 376 gem install rails includedependencies command, 375 gem install sqlite3-ruby command, 377 gem update system command, 377 gem update rails command, 375 generate program, 385–386 generate_number method, 207, 209 generic error handlers, 339 get_computer_move method, 282 get_consonants method, 240–241, 246 get_fortune method, 103, 106 get_new_card method, 315–317 get_player_move method, 281 get_question method, 103, 106 gets method, 62, 65, 93, 206, 309 get_vowel method, 242–243, 245–246 global variables, 97–98, 271–273 beginning with $ character, 273 exposing data located in other parts of program, 272 handling exceptions, 337–340 Hansson, David Heinemeier, 370 Hash class, 156, 196, 198–200, 202–203 hashes, 196 adding key-value pairs, 198–199 assigning empty list to, 199 creation, 196–198 defining, 197 deleting key-value pairs, 199– 200 determining number of keyvalue pairs, 200–201 empty, 196 key-value pairs, 197 keys, 196 listing keys, 201 listing values, 202 looping through values, 202 merging, 199 multiple-line definition, 197 populating with another hash, 198 retrieving data stored in, 201– 203 reversing order of sort, 203 sorting keys, 202–203 storing and manipulating lists, 196–203 unique keys, 199 Hello.rb script, 299 Hello.txt file, 299–302, 304 HelloWorld.rb program, 25 running, 26 Hero class, 266–268 honk method, 90–91 HTML, 371 I i modifier, 234 i variable, 163, 245 @identity variable, 264 IDEs (Integrated Development Environments), if code block, 249, 264, 286, 321 if expressions, 121, 136, 138–139 alternative actions, 124–125 checking alternative conditions, 125 creation, 123 else keyword, 124–126, 137 elsif keyword, 125 multiple elsif keywords, 128 nesting, 130 replacing if modifiers with, 124–126 series of, 130 series of elsif statements, 127 single line, 124 if modifiers, 121–122 && operator, 131 replacing with if expressions, 124–126 if statement, 62, 105, 169, 173, 190 code block, 359 nested, 318 implicit class conversion, 93 include? method, 195, 241 incomplete statements, executing, 51 indexes, 186 index.html file, 381 index.html.erb file, 386 inheritance, 52, 91–92, 266–267 initialize method, 264, 269–270, 273–274 initializing objects when instantiating, 269–271 input, collecting and storing, 135–136 conditional checks, 241 IRB (Interactive Ruby), 47 redirecting, 299–300 as string, 93 using and validating, 151 inputArray array, 310 inputFile variable, 309 411 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 411 9/3/10 11:30:16 PM INDEX 412 insert_at method, 194 inspect method, 186–187, 194, 200 installing Ruby, 17–20 instance variables, 97 beginning with @ character, 273 listing, 344 instantiating objects, 29 instantiation, 8, 52 Integer class, 58, 92, 157–160 integers, 94, 158–159 versus floating-point numbers, 56 Integrated Development Environments See IDEs Interactive Ruby See IRB Internet Explorer, 14 interpreted programming languages, 12 interpreted programs, interpreted scripting language, 10 interpreter, 9, 12 irb command, 16–17, 21–22, 46–48 IRB (Interactive Ruby), 16, 21–23 accessing online, 48–49 as calculator, 53–54 command-line options, 47–48 command prompt, 23, 47 executing incomplete statements, 51 executing Ruby statements, 49–50 feedback on code, 22 mathematical calculations, 53–56 multiple sessions, 48 options, 47 as quick command-line calculator, 53 Ruby parser, 51 scripts, 47 starting, 21 starting IRB session, 46–48 testing Ruby Scripts, 51–52 types of input, 47 version, 48 web-enabled version, 48–49 IRB (Interactive Ruby) session, 16 IRB prompt, 17 IRB sessions, 48 ending, 17 experimenting with arrays, 186 starting, 22, 46–48 stopping, 22 IRB shell, 21 irb_exit command, 48 irb(main):001:1> command prompt, 22 irb_quit command, 48 IronRuby virtual machine, 14 It is something else text message, 301 iterator, 157 It’s a folder text message, 301 J Jacquard, Joseph Marie, Jacquard loom, Java programming language, 10 Java-supported platform programs, 14 join method, 245 K KATE Editor Web site, 24 KATE (KDE Advanced Text Editor), 24 Kernel class, 161, 337 key-value pairs => character, 197 adding, 198–199 conditionally deleting, 200 deleting, 199–200 number in hash, 200–201 keys and hashes, 196 keys method, 201–202 kids hash, 197–202 Komodo IDE, 24 L language constructs, 151–154 last method, 191 length method, 87, 190, 201, 241 less than operator, 122, 123 less than or equal to operator, 122 lib folder, 382 Linux, 4, 14 command prompt, 21 command shell session, 17 forward slashes and path information, 305 installing Ruby on, 19–20 looking for Ruby on, 17 manually installing Ruby, 20 package-management utility, 20 path to files and folders, 305 root access, 20 Ruby, 15 Ruby programs creation, 24 running Ruby programs, 26 starting Interactive Ruby session, 17 /linux/ regular expression, 306 Lisp, 10 list array, 241 list command, 344 lists, 186 manipulating and storing, 186–195 storing and manipulating with hashes, 196–203 load method, 51 local variables, 90, 97–98, 271–272 beginning with letter or underscore character, 273 listing, 344 :location property, 61 Locomotive link, 19 log folder, 382 logical comparisons, combining and negating operations, 130–131 logical errors, 337 logical flow, tracking, 341–342 London Science Museum, longSound object, 270–271 loop method, 161–162 loop modifiers until modifier, 155 while modifier, 154–155 looping methods, 156–162 downto method, 159–160 each method, 156–157 loop method, 161–162 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 412 9/3/10 11:30:16 PM INDEX step method, 160–161 times method, 157–158 upto method, 158–159 loops, 104, 147, 150, 285 altering execution, 162–164 computer games, 151 controlling execution, 104–105 counting down, 159–160 endless, 152, 340 executing given number of times, 160–161 for…in loops, 153–154 hash values, 202 iterating predetermined times, 158–159 iterating through contents of array, 192 language constructs, 151–154 methods, 151 modifiers, 151 processing and validating user input, 151 processing hash keys, 201–202 re-executing, 241 repeatedly executing valid answer provided, 169 repeating current execution, 163 repeating execution of commands, 150 restarting from beginning, 164 running forever, 161, 265 running undetermined number of times, 161–162 skipping to next iteration, 163–164 terminating, 152, 161–162, 169, 172 until loops, 152–153 while loops, 151–152 Lovelace, Ada, M Mac OS X, 2, 4, 14 Applications folder, 16 command prompt, 21 finding Ruby installation, 19 installing Ruby on Rails, 376–377 looking for Ruby on, 16–17 Ruby, 15 Ruby on Rails, 370 Ruby program creation, 24 running Ruby programs, 26 starting new Ruby session, 17 Terminal application, 16 TextEdit application, 24 UNIX-shell command prompt, 16 machine code, machine language, MacPorts link, 19 MacroMates website, 24 mad-lib, 42 main object, 22 makefile file, 20 make_sound method, 270–271, 273 match variable, 245 matching patterns, 228–229, 232 Math module, accessing methods stored in, 54 math operators, 53 mathematical calculations, 275 accessing Math module methods, 54 IRB (Interactive Ruby), 53–56 operator precedence, 54–55 mathematical methods, 54 mathematical operations integers versus floating-point numbers, 56 overriding operator precedence, 55–56 mathematical operators and operator precedence, 54–55 Matz, Yukihiro Matsumoto, 10 mechanized era, 5–6 merge method, 199 merging arrays, 267–268 hashes, 199 message variable, 300 metacharacters, 230–233 methodname, 90 methods, 13, 52, 56, 88 assigning name to different, 267–268 associated with multiple classes, 58 beginning of, 90 chaining, 275 correctly entering, 54 defining, 90 documentation, 58 loops, 151 Math Module, 54 name of, 90 parameters passed to, 90 predefined, 274 restricting access, 263–265 statements executed, 90 String class, 87 Microsoft Windows, 2, 4, 14 backslashes and path information, 305 command prompt, 21 installing Ruby, 18–19 installing Ruby on Rails, 375– 376 looking for Ruby on, 15–16 one-click installer package, 18 path to files and folders, 305 program editors, 24 rb file extension, 26 Ruby, 15 Ruby program creation, 24 Ruby program group, 15 running Ruby programs, 26 SciTE editor, 24 text editors, 24 mkdir method, 303 mkdir RoR_Apps command, 384 model property, 91 Model-View-Controller architecture See MVC architecture models, 372 modifiers, 151 modifying classes, 275–276 modules, 54 Modulus (%) operator, 53 :monster property, 61 monster variable, 63 multiline text strings, 85–86 Multiplication (*) operator, 53 413 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 413 9/3/10 11:30:17 PM INDEX 414 multiplying text strings, 84–85 Mustang class, 92 MVC (Model-View-Controller) architecture, 372–373 myArray object, 275 @@myHero class variable, 274 MyList array, 153 myName local variable, 271 $myName variable, 272 MySQL, 374 N n value conditional logic, 29 name local variable, 273 Names array, 189–190 natural, English like programming languages, 12 nesting, 129 conditional statements, 129–130 if expressions, 130 unless expression, 130 NET Framework programs, 14 new line (\n) escape character, 82–84, 94 new method, 52, 89, 187, 196, 198, 306–307, 309–310 next command, 162–164 next method, 87 nil value, 23, 50, 300 Noise class, 270, 273 noOfMoves variable, 354 $noRight variable, 136–137, 169–171 not equal to (!=) operator, 122 not operator, 130 number variable, 209 numbers converting strings to, 94–95 converting to strings, 95 floating-point, 56, 94–95 integers, 56, 94 as objects, 92 square root, 54 Numeric class, 57–58, 275–276 numeric classes, 92 between? method, 128 numeric value, treating as string, 84 O object classes, 186 object-oriented programming See OOP object-oriented programming language See OOP language :object property, 61 objects, 8, 13, 88 actions affecting, 13 arrays, 186 assigning values to properties, 89–90 creation, 52 hashes, 196 identifying, 22 important features available, 262 inheritance, 52 initializing on instantiation, 269–271 instantiating, 8, 29, 52, 63, 88–90, 103, 171 interacting with, 89–90 properties, 13 referring to current, 276 @occurrences instance variable, 270 OOP language (object-oriented programming language), 88 Ruby, 10 OOP (object-oriented programming), 8, 88–92 abstraction, 262 concepts, 258 encapsulation, 263–265 inheritance, 266–267 polymorphism, 267–268 operating systems, compatible with Ruby, current working directory, 26 files and folders, 305–306 identifying, 306 installing Ruby, 17–20 Ruby, 14 where to find Ruby, 26 operator precedence, 54–55, 130 overriding, 55–56 options, 47 or operator, 130 Oracle, 374 output, redirecting, 299–300 overriding operator precedence, 55–56 P :P1 property, 61 :P2 property, 61 :P3 property, 61 :P4 property, 61 parameters, 90 parent classes, 91–92, 266 parent IRB session, 48 parents array, 188 parents hash, 199 Pascal, pattern matching, 233 multiple, 228–229 specific, 228 zero or more times, 232–233 pause method, 104, 206, 312 Perl (Practical Extraction and Report Language), 9–10 Pi constant, 99 pipe (|) character, 228–229 :place property, 61 play_dealer_hand method, 315, 317 player variable, 351, 354 playerHand argument, 317 playerMove method, 281 play_game method, 208–209, 212, 246, 249, 280–281, 286, 314–315, 321, 341– 342, 352–354, 359 polymorphism, 267–268 pop method, 193 ported, 7–8 Practical Extraction and Report Language See Perl predefined methods, 274 $prediction global variable, 103 presentation templates, 373 present_test method, 135–136, 139 print command, 49–50 print method, 103, 162 print statement, 341 executing, 49–50 private keyword, 263, 264 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 414 9/3/10 11:30:17 PM INDEX procedure oriented programming languages, procedures, production environment, 374 program editors, 24 programming, object-oriented, 88–92 structured, programming languages ADA, 10 ALGOL, assembly languages, 6–7 C, C#, C++, 8, 10 COBOL, Fortran, Java, 10 Lisp, 10 natural, English like, 12 Pascal, Perl (Practical Extraction and Report Language), 9–10 ported, 7–8 procedure oriented, Python, 10 Ruby, 10 Smalltalk, 10 Visual Basic, programs, 12 automating tasks, 14 cross-platform development, executing without stepping, 344 finding bugs, 342–346 interpreted, Java-supported platform, 14 machine language, NET Framework, 14 running slower than compiled counterparts, 12 stepping through, 344 testing, 336 prompt_for_guess method, 246 properties, 13, 88 assigning values to, 89–90 defining, 89 restricting access, 263–265 protected keyword, 263 public folder, 381, 382 public keyword, 263 push method, 190 puts command, 23, 25, 50 puts method, 103, 121–122, 157, 201, 303, 309 redirecting output, 307 puts statement, 131, 170, 341 associated with else keyword, 128 Python, 10 Q %Q{and} characters, 85 question property, 103 quit command, 48, 345 Quiz class, 166–167, 171, 174 R RAD (rapid application development), Rails, 11, 369 rails command, 385 rails demo command, 378 rails Ruby script, 379 Railties, 373 raising exceptions, 337–338 rake command, 385 rake db:create command, 385 Rakefile folder, 383 rand method, 131, 207 random number, 131, 209 randomAnswer local variable, 103 randomNo property, 103 randomNo variable, 131 Range class, 156 range operator ( ), 154 rapid application development See RAD rb file extension, 25 Microsoft Windows, 26 read method, 309–310 read mode, 309 reading data from text files, 309–310 readlines method, 310 README folder, 383 redirecting input and output, 299–300 redirection input operator (), 299–300 redo command, 162–163, 209, 241 regular-expression equals (=~) operator, 228 regular expressions, 84, 222, 227, 285 case sensitivity, 234 comparison, 241 data validation, 227 matching patterns, 228–229 metacharacters, 230–232 overcoming differences in case, 234 RUBY_PLATFORM special variable, 306 set of specified matches, 228–229 specific set of characters, 228 string substitution, 234–235 support for, 233 remainder, 56 rename method, 304 reply variable, 169, 209, 227 rescue keyword, 338–339 resources, determining if file or folder are, 301–302 result variable, 129 retrieving data, 95–98 retry command, 162, 164 retry statement, 339–340 retrying failed statements, 339–340 return (r) escape character, 82, 83 return command, 207 reverse method, 87–88, 194, 203 REXML class, 58 ri command-line Ruby documentation viewer, 57–58 Rock, Paper, Scissors game analyze_results method, 282–283 clearing screen, 278 collecting player’s move, 281 comparing player and computer move, 260, 282–283 415 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 415 9/3/10 11:30:17 PM INDEX 416 controlling execution, 279 controlling game play, 285–286 controlling interaction with user, 278 designing, 277–286 developer’s name and website, 260 display_credits method, 283–284 display_greeting method, 279 displaying result of game, 283 display_results method, 283 documenting script and purpose, 278 Game class, 279 get_computer_move method, 282 get_player_move method, 281 getting permission to start game, 284–285 how game is played, 259 information about, 283–284 instantiating objects, 284 instructions for playing, 279 managing execution of round of play, 280–281 move by computer, 282 permission to begin game, 259 play_game method, 280–281 prompting player for permission to play, 260 prompting player for Rock, Paper, or Scissors, 259 randomly selecting move for computer, 260 Ruby file creation, 278 rules, 258 running, 285–286 Screen class, 278–279 welcome screen, 258, 279 RoR, 369 RoR_Apps folder, 385 round method, 58 RPS object, 284 RPS.rb file, 278 Ruby, 10 determining if installed, 15–17 executing statements, 49–50 flexibility, 14 installing, 17–20 interpreted programming language, 12 interpreted scripting language, 10 interpreter, 12 killer application, 11 learning about elements, 23 light syntax, 13 Linux, 15 Mac OS X, 15 Microsoft Windows, 15 object-oriented programming language, 10, 13 objects, 13 open-source license, operating systems, 2, 4, 14 programs, 12 simple yet powerful, 11–13 slow recognition of, 10 statements, 13 straightforward syntax, 12 syntax rules, 50 system resources access, 12 UNIX, 15 upgrading, 17–20 version 1.9.1, 11 virtual machines, 14 website applications, 11 working with, 21–23 ruby -r debug command, 342 ruby -r debug test.rb command, 343 ruby -v command, 15–16 Ruby Blackjack game asking for additional cards, 297 complete_player_hand method, 316–317 completing dealer’s hand, 317 controlling game play, 320–321 controlling interaction with user, 312 dealing new card, 315–316 designing, 311–321 determine_winner method, 318 display_credits method, 319 display_greeting method, 313 displaying game’s credits, 319 displaying instructions, 313–314 displaying welcome message, 313 display_instructions method, 313–314 documenting script and purpose, 312 example of game player has won, 297 executing game, 312 Game class, 313 get_new_card method, 315–316 helping player play hand, 316–317 information about game and author, 297 instantiating script objects, 319 instructions for playing, 296 managing round of play, 314–315 permission to begin game, 295, 297, 319–320 player_dealer_hand method, 317 play_game method, 314–315 prompting player, 296 Ruby file creation, 312 running, 320–321 Screen class, 312 welcome message, 295 ruby command, 21, 26 Ruby Documentation, 19 Ruby editors, cross-platform, 24–25 Ruby-installation procedure, 19 Ruby interpreter automatically installing, 17 comments, 28 Ruby Joke game, 2–5 class representing computer screen, 28–29 clearing screen, 30 comments, 32 designing, 27–31 documenting, 28 executing, 35 file creation, 28 high-level conditional logic, 29 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 416 9/3/10 11:30:17 PM INDEX instantiating objects, 29 inviting player to return to play, 3, 30 joke’s punch line, permission to begin telling jokes, prompting for permission to continue, 29 purpose, 28 reviewing completed program file, 32–34 telling first joke, 30 telling remaining jokes, 30–31 thanking player, 3, 31 ruby-lang.org English-language website, 10 Ruby-Lang.org website, 18, 19, 20 Ruby libraries, 17 Ruby Number Guessing game beginning, 183 controlling execution of game, 211–212 designing, 204–212 display_credits method, 209–210 display_greeting method, 206 displaying instructions, 207 display_instructions method, 207 documenting script and purpose, 205 Game class, 206 generate_number method, 207 hints for player, 184 information about game and developer, 209–210 instantiating script objects, 210 instructions, 184 NumberGuess.rb file, 205 permission to play game, 182, 185, 210–211 player guesses, 184–185, 209 play_game method, 208–209 random number, 207, 209 Ruby file creation, 205 running, 212 Screen class, 205–206 terminating, 183 welcome screen, 182, 206 Ruby on Rails, 11, 14, 369 Action Controller, 373 Action Mailer, 373 Active Record library, 372–373 Active Resource, 373 Active Support, 373 Active View library, 373 additional libraries, 373 architecture, 372–373 controllers, 372, 373 convention over configuration, 371 CSS (Cascading Style Sheets), 371 database management systems, 374 demo project, 377, 378–379 development philosophy, 371–372 directory structure, 381 DRY (Don’t Repeat Yourself ), 372 home page, 381 installing, 375–377 learning more about, 387–388 Mac OS X, 370 models, 372 MVC (Model-ViewController) architecture, 372–373 overview, 369–374 Railties, 373 required software, 371 skills needed, 371 updating, 375 verifying setup, 377–383 views, 372 “Welcome aboard” page, 387 Ruby on Rails applications customizing, 370 environments, 374 files, 381–383 views, 373 web servers, 377 Ruby on Rails blog application, 369 controller and view creation, 385–386 database for application creation, 385 designing, 384–386 editing application’s index page, 386 folder creation, 384–385 Ruby on Rails application creation, 385 running, 386–387 starting web server, 386–387 viewing, 387 Ruby on Rails documentation site, 387–388 Ruby on Rails website, 370, 380, 387 Ruby One-Click Installer link, 18 Ruby parser, 51 Ruby programs comments, 28 creation, 25 developing, 24–26 documenting, 28 as executable file, 26 executing, 35 folders, 25 purpose, 28 running, 26, 32–35 ruby RubyJoke.rb command, 35 ruby script/server command, 379, 386 Ruby scripts complete name, 47 executing, 51 indentation, 61 path, 47 testing, 51–52 ruby-talk mailing list, 10 Ruby Tall Tale game answering series of questions, 59 building game’s story, 63–64 clearing screen, 61 code listing, 65–69 collecting player input, 62–63 defining classes, 61 designing, 60–65 documenting script and purpose, 60 encouraging player to play, 43 file creation, 60 happy conclusion to story, 45 417 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 417 9/3/10 11:30:17 PM INDEX 418 heroes arrive to save day, 45 high-level conditional logic, 62 inserts input into story’s plot, 44 permission to begin game, 42 prematurely terminating game, 62 preparing for execution, 61 prompting player to provide information, 43 running, 65–69 telling game’s story, 64–65 thanking player, 65 ruby TallTale.rb command, 69 Ruby Tic-Tac-Toe game check_results method, 355–356 clear_game_board method, 354–355 controlling game play, 358–359 controlling interaction with user, 348 designing, 347–359 display_credits method, 357 display_game_board method, 350–351 display_game_results method, 356 display_greeting method, 349 display_instructions method, 349–350 documenting script and purpose, 348 executing game, 348 game board, 351–352 Game class, 349 game instructions, 333, 350 information about game and developer, 357 initializing script objects, 357 managing play, 352–354 moves, 334 permission to begin game, 332 permission to start game, 335, 358 play_game method, 352–354 results of current round, 356 Ruby file creation, 348 running, 358 Screen class, 348 three squares in a row, 355–356 validate_player_move method, 352 variable references, 351 welcome screen, 332, 349 winning, 334 Ruby Typing Challenge game class representing console window, 133–134 class representing typing test, 134 clearing screen, 139 controlling logic, 138 designing, 132–139 determine_grade method, 136–137 display_greeting method, 134–135 display_instructions method, 135 documenting script and purpose, 133 evaluating accuracy of typing skills, 115 executing typing test, 139 game termination, 138–139 instantiating script objects, 137 instructions, 116–117 permission to begin test, 116, 137–138 player has passed typing test, 136–137 present_test method, 135– 136 Ruby file creation, 133 running, 140 taking test again, 139 thanking player, 118 typing sentence exactly, 117 welcome screen, 115, 135 Ruby Virtual Crazy 8-Ball game analyzing player’s response, 105 asking new question, 79–80 Ball class, 101–103 confirmation to continue, 104–105 designing, 100–107 documenting script and purpose, 100–101 early termination of game, 105 greeting player, 104 instantiating objects, 103 instructing player to respond, 78 randomly selected answers, 80 responding to questions, 105–107 Ruby script file, 100 running, 107 Screen class, 101 thanking player for playing, 81 welcome screen, 78 Ruby Word Guessing game clue to secret word, 225 controlling game play, 248–249 correct answer displayed, 226 designing, 236–249 display_credits method, 247 display_greeting method, 238 displaying game’s credits, 247 display_instructions method, 238–239 documenting script and purpose, 237 formatting secret word, 245 Game class, 238 get_consonants method, 240–241 get_vowel method, 242–243 guessing secret word, 225, 226 how to play game, 223 input validated in conditional checks, 241 instantiating script objects, 247 instructions for playing, 239 interaction with player, 245 permission to begin game, 223, 226 permission to start game, 247–248 player providing consonants, 241 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 418 9/3/10 11:30:17 PM INDEX player providing vowel, 242–243 play_game method, 246 prompt_for_guess method, 243–246 putting words in array, 239–240 random guesses, 222 retrieving word, 246 Ruby file creation, 237 running, 249 Screen class, 237–238 select_word method, 239–240 specifying consonants, 224 specifying vowel, 225 welcome screen, 222, 238 ruby-X.X.X.tar.gz file, 20 RubyForge website, 24–25 RubyGems package manager, 19, 371, 374, 375 most current version, 377 RubyGems website, 376 RubyJoke.rb file, 28 Ruby.org website, 48, 57 RUBY_PLATFORM special variable, 306 Ruby_Scripts folder, 26 running Ruby programs, 26 runtime errors, 336 division-by-zero, 340 S say_goodbye method, 103 say_greeting method, 103, 104 SciTE code editor, 19, 24 scope increasing, 273 variables, 97–98, 271–274 screen, displaying, 49–50 Screen class, 28–30, 52, 61, 65, 101, 104, 133–134, 166–167, 205–206, 210, 237–238, 247, 312, 348 instantiating instances, 137 template, 29 testing execution, 51–52 Screen object, 52, 103 script errors accessing error information, 338–339 handling different types of errors, 339 logical errors, 337 programs terminating, 338 runtime errors, 336 syntax errors, 336 types, 335–337 script folder, 382 scripting languages, 9, 10 scripts, 9, 12, 47 adaptive, 119–121 complete name, 47 conditional logic statements, 105 copying and pasting statements, 51 data validation logic, 227 documenting, 60, 100–101 executing, 51 indentation, 61 outlining conditional logic, 62 path, 47 purpose, 60, 100–101 representing logical flow, 120 testing, 51–52 tracking logical flow, 341–342 searching arrays, 195 secret_identity method, 264 select_word method, 246 sentences, displaying, 135–136 shebang statements, 26 shell, history of commands entered, 21–22 shift method, 193 shortSound object, 270–271 shortWord argument, 245–246 single dot (.) character, 26 size method, 190, 201, 302 slice method, 191 Smalltalk, 10 sort method, 194, 203, 274 sorting alphabetical array contents, 194 arrays, 194, 274 hash keys, 202–203 reverse alphabetical order, 194 reversing order, 203 space (s) escape character, 82 split method, 245 SQ object, 171, 173, 210 SQL Server, 374 SQLite database management system, 374 demo project, 379 installing, 377 SQLite web server, 371 sqrt method, 54 square root, 54 standard input Se STDIN standard output See STDOUT Start > All Programs > Accessories > Command Prompt command, 15, 26 statements conditional test to end of, 122 executing, 49–50 executing each time loop repeats, 151 executing if true or false, 122–123 executing incomplete, 51 executing multiple, 123 executing when method called, 90 repeatedly executed, 158–159 repeatedly executing, 157–158 retrying failed, 339–340 statements placeholder, 88, 90 STDIN class, 62, 65, 93, 206 STDIN (standard input), 299 redirecting, 299–300 STDOUT (standard output), 299 redirecting, 299 step command, 344 debugger, 343 stepping through program, 344 storing data, 95–98 Story object, 63 story variable, 87 storytelling game, 42 string arrays, 187 String class, 84, 106, 234, 241, 245–246 methods, 87 string interpolation, 83 %Q characters, 85 strings character at beginning and end, 232 419 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 419 9/3/10 11:30:17 PM INDEX 420 concatenating, 267 converting numeric value to, 95 converting to numbers, 94–95 delimiter, 245 displaying, 49–50 embedding text string in, 83 input as, 93 length, 87 manipulating contents, 83–86 matches within, 227 matching pattern at end, 232 modifying through character substitution, 234–235 multiple lines, 85–86 number of characters, 87 as objects, 92 regular expressions, 84 removing character from, 94 reversing order of characters, 88 separate lines for, 50 substituting value of expression or variable in, 83 treating numeric value as, 84 uppercase characters, 87–88 structured programming, sub method, 234–235 subclasses See child class Subtraction operator (-), 53 array creation, 188 sudo gem install rails includedependencies command, 377 sudo ruby setup.rb command, 376 superCar object, 89 superclass operator, 92 Superhero class, 263–264 Superman class, 267, 274 Superman Movie Trivia Quiz administering quiz, 172–174 advancing to next question, 149 closing screen, 150 controlling quiz execution, 167 designing, 165–174 determine_grade method, 170–171 determining if player passed, 170–171 display_credits method, 171 display_greeting method, 167 displaying instructions, 148 displaying questions, 149 display_instructions method, 168 disp_q method, 168–169 documenting script and purpose, 166 Good Citizen ranking, 170 information about quiz and developer, 171 instantiating objects, 171 instructions, 168 permission to begin quiz, 147 permission to start, 172 processing player’s answers, 168–169 Quiz class, 167 quiz questions, 168–169 rejecting invalid input, 227 Ruby file creation, 166 running, 174 Screen class, 166–167 Side Kick rank, 171 specify letter representing possible answer, 149 Superhero rank, 171 welcome message, 147 welcome screen, 167 SupermanQuiz.rb file, 166 swapcase method, 87 syntactical information about elements, 23 syntax errors, 336 syntax rules, 50 system method, 337 T tab (t) escape character, 82 Tale class, 61, 63, 65 TallTale.rb file, 60 tasks, automating, 14 tell_fortune method, 103, 106 tell_Story method, 61, 65 templates, 52 classes as, 262 instantiating objects, 89 Screen class, 29 Terminal application, 16 ternary operator (?:), 121, 129 Test class, 137 test environment, 374 test folder, 382 TestDir folder, 303 test.rb file, 342 text displaying, 23, 49–50 separate lines for, 50 text editors, 24 text files administering, 300–304 appending data to end of, 308 reading data from, 309–310 reference to, 306 saving files as, 24 writing data to, 307 text strings assigning to variable, 95 comparing, 85 concatenating, 84 creation, 81–82 displaying, 25 embedding in string, 83 embedding within %Q {and} characters, 64 enclosing in double quotation marks, 64, 81–82 enclosing in single quotation marks, 81–82 escape characters, 82 game instructions, 135 modifying format, 82 multiline, 85–86 multiplying, 84–85 uppercase and lowercase letters, 246 TextEdit, Preferences, Plain text command, 24 TextEdit application, 24 TextMate, 24 third generation computers, TicTacToe.rb file, 348 times method, 157–158 tmp folder, 382 to_f method, 94–95 to_i method, 94 to_s method, 84, 95 TotalCount variable, 96 totalcount variable, 96 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 420 9/3/10 11:30:17 PM INDEX totalScore variable, 83 Try Ruby! web page, 48 TTT object, 357 Typingchallenge.rb file, 133 Typing_Test object, 137, 139 U unassigned value, 50 Undefined local variable or method error message, 271 UnderDog class, 267, 268 Uninstall Ruby-XXX-XX application, 19 UNIX, 14 command prompt, 21 command shell session, 17 forward slashes and path information, 305 installing Ruby on, 19–20 logged on with root access, 20 looking for Ruby on, 17 manually installing Ruby, 20 package-management utility, 20 path to files and folders, 305 Ruby, 15 Ruby programs creation, 24 running Ruby programs, 26 starting Interactive Ruby session, 17 UNIX-shell command prompt, 16 Unknown value, 264 unless expression, 121 creation, 126 nesting, 130 unless modifier, 121, 122–123 until loops, 152–153, 192 until modifier, 155 upcase method, 87, 88 upgrading Ruby, 17–20 upto method, 158–159 user-friendly error message, 339 userName parameter, 273 values arc cosine, 54 cosine, 54 negating or reversing, 131 unassigned, 50 values method, 202 var global command, 344 var instance command, 344 var local command, 343–344 variable references, 351 variable substitution, 63, 83 variableName, 89 variables, 13, 95, 186 accessing contents, 13 assigning lowest level of scope, 271 assigning text string to, 95 assignment as result of comparison, 129 assignments, 96–97 class, 97, 273–274 declaring, 13 global, 97, 98, 271–273 increasing scope, 273 instance, 97, 273 iterator, 157 local, 90, 97, 98, 271, 272 naming, 52, 96 raising value by increment, 97 restricting access, 272 scope, 97–98, 271–274 substituting value of, 83 valid and invalid names, 96 value of, 343–345 vendor folder, 382 vi editor, 24 views, 372, 373 :villain property, 61 virtual machine, 14 Visual Basic, vowel argument, 245, 246 W V validate_player_move method, 351, 352 value of nothing, 23 WAN (wide area networking), %w(and) characters, 187 watch command, 345 watchpoint, 345 web-based applications automating creation, 369 development and execution of, 14 web-page construction, 371 web servers accessing locally installed, 380 Ruby on Rails applications, 377 WEBrick web server, 377 halting execution, 381 monitoring port 3000, 380 starting, 386–387 verifying execution, 379–381 website applications, 11 when statements, 127–129 while loops, 151–152, 192 while modifier, 154–155 wide area networking See WAN Windows command prompt, 15–16 Windows console window, 26 word argument, 245, 246 word processing features, 24 wordArray array, 245 WordGuess object, 247 WordGuess.rb file, 237 words array, 239–241 writing data to text files, 307 421 X x array, 187 x variable, 93, 95, 97–98, 152–153, 157, 193, 201, 234, 275 possible values of, 125 value assigned, 343 value of, 344–345 $x variable, 98 Y y array, 187 y value, 29 y variable, 95, 98 Z z variable, 95 Copyright 2010 Cengage Learning All Rights Reserved May not be copied, scanned, or duplicated, in whole or in part Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s) Editorial review has deemed that any suppressed content does not materially affect the overall learning experience Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it C7656_index.indd 421 9/3/10 11:30:17 PM ... Library of Congress Control Number: 2 0109 35900 ISBN-13: 978-1-111 -222 37-6 ISBN -10: 1-111 -222 37-1 Course Technology 20 Channel Center Street Boston, MA 02 210 Cengage Learning is a leading provider... 222 227 228 228 228 230 231 231 231 232 232 232 233 233 234 234 236 236 249 Copyright 2 010 Cengage Learning All Rights Reserved May not be copied,... C7656_fm.indd xvi 03/09 /10 10:36 PM P R E FA C E • RubyGems A Ruby package that facilitates the installation of Ruby on Rails and related components RubyGems is automatically installed with Ruby on Microsoft

Ngày đăng: 07/01/2017, 20:48

Từ khóa liên quan

Mục lục

  • Cover Page

  • Title Page

  • Copyright Page

  • Brief Contents

  • Contents

  • Preface

    • The Approach

      • Overview of This Book

      • Features

      • Instructor Resources

      • Acknowledgements

      • Requirements for Completing this Book

      • To the Instructor

        • Course Technology Data Files

        • Visit Our Web Site

        • CHAPTER 1: Ruby Basics

          • Project Preview: The Ruby Joke Game

          • A Brief History of Computers and Computer Programming

            • The Mechanized Era

            • The First Generation

            • The Second Generation

            • The Third Generation

            • The Fourth Generation

            • The Fifth Generation

            • 1990 and Beyond

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan