| | Copyright |
| | |
| | Foreword |
| | Acknowledgments |
| | About the Author |
| | Introduction |
| | Chapter 1. Ruby in Review |
| | | Section 1.1. An Introduction to Object Orientation |
| | | Section 1.2. Basic Ruby Syntax and Semantics |
| | | Section 1.3. OOP in Ruby |
| | | Section 1.4. Dynamic Aspects of Ruby |
| | | Section 1.5. Training Your Intuition: Things to Remember |
| | | Section 1.6. Ruby Jargon and Slang |
| | | Section 1.7. Conclusion |
| | Chapter 2. Working with Strings |
| | | Section 2.1. Representing Ordinary Strings |
| | | Section 2.2. Representing Strings with Alternate Notations |
| | | Section 2.3. Using Here-Documents |
| | | Section 2.4. Finding the Length of a String |
| | | Section 2.5. Processing a Line at a Time |
| | | Section 2.6. Processing a Byte at a Time |
| | | Section 2.7. Performing Specialized String Comparisons |
| | | Section 2.8. Tokenizing a String |
| | | Section 2.9. Formatting a String |
| | | Section 2.10. Using Strings As IO Objects |
| | | Section 2.11. Controlling Uppercase and Lowercase |
| | | Section 2.12. Accessing and Assigning Substrings |
| | | Section 2.13. Substituting in Strings |
| | | Section 2.14. Searching a String |
| | | Section 2.15. Converting Between Characters and ASCII Codes |
| | | Section 2.16. Implicit and Explicit Conversion |
| | | Section 2.17. Appending an Item Onto a String |
| | | Section 2.18. Removing Trailing Newlines and Other Characters |
| | | Section 2.19. Trimming Whitespace from a String |
| | | Section 2.20. Repeating Strings |
| | | Section 2.21. Embedding Expressions Within Strings |
| | | Section 2.22. Delayed Interpolation of Strings |
| | | Section 2.23. Parsing Comma-Separated Data |
| | | Section 2.24. Converting Strings to Numbers (Decimal and Otherwise) |
| | | Section 2.25. Encoding and Decoding rot13 Text |
| | | Section 2.26. Encrypting Strings |
| | | Section 2.27. Compressing Strings |
| | | Section 2.28. Counting Characters in Strings |
| | | Section 2.29. Reversing a String |
| | | Section 2.30. Removing Duplicate Characters |
| | | Section 2.31. Removing Specific Characters |
| | | Section 2.32. Printing Special Characters |
| | | Section 2.33. Generating Successive Strings |
| | | Section 2.34. Calculating a 32-Bit CRC |
| | | Section 2.35. Calculating the MD5 Hash of a String |
| | | Section 2.36. Calculating the Levenshtein Distance Between Two Strings |
| | | Section 2.37. Encoding and Decoding base64 Strings |
| | | Section 2.38. Encoding and Decoding Strings (uuencode/uudecode) |
| | | Section 2.39. Expanding and Compressing Tab Characters |
| | | Section 2.40. Wrapping Lines of Text |
| | | Section 2.41. Conclusion |
| | Chapter 3. Working with Regular Expressions |
| | | Section 3.1. Regular Expression Syntax |
| | | Section 3.2. Compiling Regular Expressions |
| | | Section 3.3. Escaping Special Characters |
| | | Section 3.4. Using Anchors |
| | | Section 3.5. Using Quantifiers |
| | | Section 3.6. Positive and Negative Lookahead |
| | | Section 3.7. Accessing Backreferences |
| | | Section 3.8. Using Character Classes |
| | | Section 3.9. Extended Regular Expressions |
| | | Section 3.10. Matching a Newline with a Dot |
| | | Section 3.11. Using Embedded Options |
| | | Section 3.12. Using Embedded Subexpressions |
| | | Section 3.13. Ruby and Oniguruma |
| | | Section 3.14. A Few Sample Regular Expressions |
| | | Section 3.15. Conclusion |
| | Chapter 4. Internationalization in Ruby |
| | | Section 4.1. Background and Terminology |
| | | Section 4.2. Coding in a Post-ASCII World |
| | | Section 4.3. Using Message Catalogs |
| | | Section 4.4. Conclusion |
| | Chapter 5. Performing Numerical Calculations |
| | | Section 5.1. Representing Numbers in Ruby |
| | | Section 5.2. Basic Operations on Numbers |
| | | Section 5.3. Rounding Floating Point Values |
| | | Section 5.4. Comparing Floating Point Numbers |
| | | Section 5.5. Formatting Numbers for Output |
| | | Section 5.6. Formatting Numbers with Commas |
| | | Section 5.7. Working with Very Large Integers |
| | | Section 5.8. Using BigDecimal |
| | | Section 5.9. Working with Rational Values |
| | | Section 5.10. Matrix Manipulation |
| | | Section 5.11. Working with Complex Numbers |
| | | Section 5.12. Using mathn |
| | | Section 5.13. Finding Prime Factorization, GCD, and LCM |
| | | Section 5.14. Working with Prime Numbers |
| | | Section 5.15. Implicit and Explicit Numeric Conversion |
| | | Section 5.16. Coercing Numeric Values |
| | | Section 5.17. Performing Bit-level Operations on Numbers |
| | | Section 5.18. Performing Base Conversions |
| | | Section 5.19. Finding Cube Roots, Fourth Roots, and so on |
| | | Section 5.20. Determining the Architecture's Byte Order |
| | | Section 5.21. Numerical Computation of a Definite Integral |
| | | Section 5.22. Trigonometry in Degrees, Radians, and Grads |
| | | Section 5.23. More Advanced Trigonometry |
| | | Section 5.24. Finding Logarithms with Arbitrary Bases |
| | | Section 5.25. Finding the Mean, Median, and Mode of a Data Set |
| | | Section 5.26. Variance and Standard Deviation |
| | | Section 5.27. Finding a Correlation Coefficient |
| | | Section 5.28. Generating Random Numbers |
| | | Section 5.29. Caching Functions with memoize |
| | | Section 5.30. Conclusion |
| | Chapter 6. Symbols and Ranges |
| | | Section 6.1. Symbols |
| | | Section 6.2. Ranges |
| | | Section 6.3. Conclusion |
| | Chapter 7. Working with Times and Dates |
| | | Section 7.1. Determining the Current Time |
| | | Section 7.2. Working with Specific Times (Post-epoch) |
| | | Section 7.3. Determining the Day of the Week |
| | | Section 7.4. Determining the Date of Easter |
| | | Section 7.5. Finding the Nth Weekday in a Month |
| | | Section 7.6. Converting Between Seconds and Larger Units |
| | | Section 7.7. Converting To and From the Epoch |
| | | Section 7.8. Working with Leap Seconds: Don't! |
| | | Section 7.9. Finding the Day of the Year |
| | | Section 7.10. Validating a Date/Time |
| | | Section 7.11. Finding the Week of the Year |
| | | Section 7.12. Detecting Leap Years |
| | | Section 7.13. Obtaining the Time Zone |
| | | Section 7.14. Working with Hours and Minutes Only |
| | | Section 7.15. Comparing Date/Time Values |
| | | Section 7.16. Adding Intervals to Date/Time Values |
| | | Section 7.17. Computing the Difference in Two Date/Time Values |
| | | Section 7.18. Working with Specific Dates (Pre-epoch) |
| | | Section 7.19. Interconverting Between Time, Date, and DateTime |
| | | Section 7.20. Retrieving a Date/Time Value from a String |
| | | Section 7.21. Formatting and Printing Date/Time Values |
| | | Section 7.22. Time Zone Conversions |
| | | Section 7.23. Determining the Number of Days in a Month |
| | | Section 7.24. Dividing a Month into Weeks |
| | | Section 7.25. Conclusion |
| | Chapter 8. Arrays, Hashes, and Other Enumerables |
| | | Section 8.1. Working with Arrays |
| | | Section 8.2. Working with Hashes |
| | | Section 8.3. Enumerables in General |
| | | Section 8.4. Conclusion |
| | Chapter 9. More Advanced Data Structures |
| | | Section 9.1. Working with Sets |
| | | Section 9.2. Working with Stacks and Queues |
| | | Section 9.3. Working with Trees |
| | | Section 9.4. Working with Graphs |
| | | Section 9.5. Conclusion |
| | Chapter 10. I/O and Data Storage |
| | | Section 10.1. Working with Files and Directories |
| | | Section 10.2. Performing Higher-Level Data Access |
| | | Section 10.3. Using KirbyBase |
| | | Section 10.4. Connecting to External Databases |
| | | Section 10.5. Conclusion |
| | Chapter 11. OOP and Dynamic Features in Ruby |
| | | Section 11.1. Everyday OOP Tasks |
| | | Section 11.2. More Advanced Techniques |
| | | Section 11.3. Working with Dynamic Features |
| | | Section 11.4. Conclusion |
| | Chapter 12. Graphical Interfaces for Ruby |
| | | Section 12.1. Ruby/Tk |
| | | Section 12.2. Ruby/GTK2 |
| | | Section 12.3. FXRuby (FOX) |
| | | Section 12.4. QtRuby |
| | | Section 12.5. Other GUI Toolkits |
| | | Section 12.6. Conclusion |
| | Chapter 13. Threads in Ruby |
| | | Section 13.1. Creating and Manipulating Threads |
| | | Section 13.2. Synchronizing Threads |
| | | Section 13.3. Conclusion |
| | Chapter 14. Scripting and System Administration |
| | | Section 14.1. Running External Programs |
| | | Section 14.2. Command-Line Options and Arguments |
| | | Section 14.3. The Shell Library |
| | | Section 14.4. Accessing Environment Variables |
| | | Section 14.5. Scripting in Microsoft Windows |
| | | Section 14.6. The Windows One-Click Installer |
| | | Section 14.7. Libraries You Need to Know About |
| | | Section 14.8. Working with Files, Directories, and Trees |
| | | Section 14.9. Miscellaneous Scripting Tasks |
| | | Section 14.10. Conclusion |
| | Chapter 15. Ruby and Data Formats |
| | | Section 15.1. Parsing XML with REXML |
| | | Section 15.2. Working with RSS and Atom |
| | | Section 15.3. Manipulating Image Data with RMagick |
| | | Section 15.4. Creating PDF Documents with PDF::Writer |
| | | Section 15.5. Conclusion |
| | Chapter 16. Testing and Debugging |
| | | Section 16.1. Testing with Test::Unit |
| | | Section 16.2. The ZenTest Tools |
| | | Section 16.3. Using the Ruby Debugger |
| | | Section 16.4. Using irb As a Debugger |
| | | Section 16.5. Measuring Code Coverage |
| | | Section 16.6. Measuring Performance |
| | | Section 16.7. Prettyprinting Objects |
| | | Section 16.8. Conclusion |
| | Chapter 17. Packaging and Distributing Code |
| | | Section 17.1. Using RDoc |
| | | Section 17.2. Installation and Packaging |
| | | Section 17.3. RubyForge and the RAA |
| | | Section 17.4. Conclusion |
| | Chapter 18. Network Programming |
| | | Section 18.1. Network Servers |
| | | Section 18.2. Network Clients |
| | | Section 18.3. Conclusion |
| | Chapter 19. Ruby and Web Applications |
| | | Section 19.1. CGI Programming with Ruby |
| | | Section 19.2. Using FastCGI |
| | | Section 19.3. Ruby on Rails |
| | | Section 19.4. Web Development with Nitro |
| | | Section 19.5. An Introduction to Wee |
| | | Section 19.6. Web Development with IOWA |
| | | Section 19.7. Ruby and the Web Server |
| | | Section 19.8. Conclusion |
| | Chapter 20. Distributed Ruby |
| | | Section 20.1. An Overview: Using drb |
| | | Section 20.2. Case Study: A Stock Ticker Simulation |
| | | Section 20.3. Rinda: A Ruby Tuplespace |
| | | Section 20.4. Service Discovery with Distributed Ruby |
| | | Section 20.5. Conclusion |
| | Chapter 21. Ruby Development Tools |
| | | Section 21.1. Using RubyGems |
| | | Section 21.2. Using Rake |
| | | Section 21.3. Using irb |
| | | Section 21.4. The ri Utility |
| | | Section 21.5. Editor Support |
| | | Section 21.6. Integrated Development Environments |
| | | Section 21.7. Conclusion |
| | Chapter 22. The Ruby Community |
| | | Section 22.1. Web Resources |
| | | Section 22.2. Newsgroup and Mailing Lists |
| | | Section 22.3. Blogs and Online Magazines |
| | | Section 22.4. Ruby Change Requests |
| | | Section 22.5. IRC Channels |
| | | Section 22.6. Ruby Conferences |
| | | Section 22.7. Local Ruby Groups |
| | | Section 22.8. Conclusion |
| | Index |