Book description
Ruby is an agile object-oriented language, borrowing some of the best features from LISP, Smalltalk, Perl, CLU, and other languages. Its popularity has grown tremendously in the five years since the first edition of this book.
The Ruby Way takes a “how-to” approach to Ruby programming with the bulk of the material consisting of more than 400 examples arranged by topic. Each example answers the question “How do I do this in Ruby?” Working along with the author, you are presented with the task description and a discussion of the technical constraints. This is followed by a step-by-step presentation of one good solution. Along the way, the author provides detailed commentary and explanations to aid your understanding.
Coverage includes
• An overview of Ruby, explaining terminology and basic principles
• Operations on low-level data types (numbers, strings, regular expressions, dates)
• The new regular expression engine (Oniguruma)
• Internationalization (I18N) and message catalogs in Ruby
• Operations on hashes, arrays, and other data structures such as stacks, trees, and graphs
• Working with general I/O, files, and persistent objects
• Database coverage including MySQL, SQLite, Oracle, DBI, and more
• Ruby-specific techniques in OOP and dynamic programming
• Graphical interfaces in Ruby (Tk, GTK+, Fox, and Qt)
• Working with Ruby threads for lightweight multitasking
• Everyday scripting and system administration in Ruby
• Working with image files, PDFs, YAML, XML, RSS, and Atom
• Testing, debugging, profiling, and packaging Ruby code
• Low-level network programming and client-server interaction
• Web development tools including Rails, Nitro, Wee, IOWA, and more
• Working with distributed Ruby, Rinda, and Ring
• Ruby development tools such as IDEs, documentation tools, and more
The source code for the book can be downloaded from www.rubyhacker.com
Hal Fulton has worked for over 15 years with variousforms of Unix, including AIX, Solaris, and Linux. He was first exposed to Ruby in 1999, and in 2001 he began work on the first edition of this book–the second Ruby book published in the English language. He has attendednumerous Ruby conferences and has given presentations at several of those, including the first European Ruby Conference.
He has two degrees in computer science from the University of Mississippi and taught computer science for four years before moving to Austin, Texas to work as a contractor for variouscompanies, including IBM Austin. Hal currently works at Broadwing Communications in Austin, Texas, maintaining a large data warehouse and related telecom applications, working daily with C++, Oracle, and, of course, Ruby.
Table of contents
- Copyright
- Foreword
- Acknowledgments
- About the Author
- Introduction
- Ruby in Review
-
Working with Strings
- Representing Ordinary Strings
- Representing Strings with Alternate Notations
- Using Here-Documents
- Finding the Length of a String
- Processing a Line at a Time
- Processing a Byte at a Time
- Performing Specialized String Comparisons
- Tokenizing a String
- Formatting a String
- Using Strings As IO Objects
- Controlling Uppercase and Lowercase
- Accessing and Assigning Substrings
- Substituting in Strings
- Searching a String
- Converting Between Characters and ASCII Codes
- Implicit and Explicit Conversion
- Appending an Item Onto a String
- Removing Trailing Newlines and Other Characters
- Trimming Whitespace from a String
- Repeating Strings
- Embedding Expressions Within Strings
- Delayed Interpolation of Strings
- Parsing Comma-Separated Data
- Converting Strings to Numbers (Decimal and Otherwise)
- Encoding and Decoding rot13 Text
- Encrypting Strings
- Compressing Strings
- Counting Characters in Strings
- Reversing a String
- Removing Duplicate Characters
- Removing Specific Characters
- Printing Special Characters
- Generating Successive Strings
- Calculating a 32-Bit CRC
- Calculating the MD5 Hash of a String
- Calculating the Levenshtein Distance Between Two Strings
- Encoding and Decoding base64 Strings
- Encoding and Decoding Strings (uuencode/uudecode)
- Expanding and Compressing Tab Characters
- Wrapping Lines of Text
- Conclusion
-
Working with Regular Expressions
- Regular Expression Syntax
- Compiling Regular Expressions
- Escaping Special Characters
- Using Anchors
- Using Quantifiers
- Positive and Negative Lookahead
- Accessing Backreferences
- Using Character Classes
- Extended Regular Expressions
- Matching a Newline with a Dot
- Using Embedded Options
- Using Embedded Subexpressions
- Ruby and Oniguruma
- A Few Sample Regular Expressions
- Conclusion
- Internationalization in Ruby
-
Performing Numerical Calculations
- Representing Numbers in Ruby
- Basic Operations on Numbers
- Rounding Floating Point Values
- Comparing Floating Point Numbers
- Formatting Numbers for Output
- Formatting Numbers with Commas
- Working with Very Large Integers
- Using BigDecimal
- Working with Rational Values
- Matrix Manipulation
- Working with Complex Numbers
- Using mathn
- Finding Prime Factorization, GCD, and LCM
- Working with Prime Numbers
- Implicit and Explicit Numeric Conversion
- Coercing Numeric Values
- Performing Bit-level Operations on Numbers
- Performing Base Conversions
- Finding Cube Roots, Fourth Roots, and so on
- Determining the Architecture’s Byte Order
- Numerical Computation of a Definite Integral
- Trigonometry in Degrees, Radians, and Grads
- More Advanced Trigonometry
- Finding Logarithms with Arbitrary Bases
- Finding the Mean, Median, and Mode of a Data Set
- Variance and Standard Deviation
- Finding a Correlation Coefficient
- Generating Random Numbers
- Caching Functions with memoize
- Conclusion
- Symbols and Ranges
-
Working with Times and Dates
- Determining the Current Time
- Working with Specific Times (Post-epoch)
- Determining the Day of the Week
- Determining the Date of Easter
- Finding the Nth Weekday in a Month
- Converting Between Seconds and Larger Units
- Converting To and From the Epoch
- Working with Leap Seconds: Don’t!
- Finding the Day of the Year
- Validating a Date/Time
- Finding the Week of the Year
- Detecting Leap Years
- Obtaining the Time Zone
- Working with Hours and Minutes Only
- Comparing Date/Time Values
- Adding Intervals to Date/Time Values
- Computing the Difference in Two Date/Time Values
- Working with Specific Dates (Pre-epoch)
- Interconverting Between Time, Date, and DateTime
- Retrieving a Date/Time Value from a String
- Formatting and Printing Date/Time Values
- Time Zone Conversions
- Determining the Number of Days in a Month
- Dividing a Month into Weeks
- Conclusion
- Arrays, Hashes, and Other Enumerables
- More Advanced Data Structures
- I/O and Data Storage
- OOP and Dynamic Features in Ruby
- Graphical Interfaces for Ruby
- Threads in Ruby
- Scripting and System Administration
- Ruby and Data Formats
- Testing and Debugging
- Packaging and Distributing Code
- Network Programming
- Ruby and Web Applications
- Distributed Ruby
- Ruby Development Tools
- The Ruby Community
- Index
Product information
- Title: The Ruby Way: Solutions and Techniques in Ruby Programming, Second Edition
- Author(s):
- Release date: October 2006
- Publisher(s): Addison-Wesley Professional
- ISBN: 0768667208
You might also like
book
The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition
For more than a decade, Ruby developers have turned to The Ruby Way for reliable “how-to” …
book
Comprehensive Ruby Programming
This book will provide you with all of the tools you need to be a professional …
book
Effective Ruby: 48 Specific Ways to Write Better Ruby
If you’re an experienced Ruby programmer, will help you harness Ruby’s full power to write more …
book
Design Patterns in Ruby
Praise for Design Patterns in Ruby " documents smart ways to resolve many problems that Ruby …