Ruby in a Nutshell

Book description

Ruby is an absolutely pure object-oriented scripting language written in C and designed with Perl and Python capabilities in mind. While its roots are in Japan, Ruby is slowly but surely gaining ground in the US. The goal of Yukihiro Matsumoto, creator of Ruby and author of this book, is to incorporate the strengths of languages like Perl, Python, Lisp and Smalltalk. Ruby is a genuine attempt to combine the best of everything in the scripting world. Since 1993, Ruby mailing lists have been established, Web pages have formed, and a community has grown around it. The language itself is very good at text processing and is notable for its broad object orientation. Ruby is portable and runs under GNU/Linux (and other Unices) as well as DOS, MS Windows and Mac.With Ruby in a Nutshell, Matsumoto offers a practical reference to the features of this new language including the command-line options, syntax, built-in variables, functions, and many commonly used classes and modules. This guide covers the current stable version of Ruby (1.6), yet is applicable to the development version 1.7 and the next planned stable version 1.8. You will find a thorough description of Ruby's language syntax, and a description of the core functionality built into the standard Ruby interpreter, which has more than 800 built-in methods in 42 classes and modules.Ruby finds its power through its built-in libraries, and this handy volume take you through the many useful libraries that come with the standard Ruby distribution--from network access via HTTP and CGI programming, to data persistence using the DBM library. This book concludes with coverage of the unique tools that come with Ruby, including the debugger, profiler, and irb (or interactive ruby.)Find out how Ruby combines the strengths of other languages, and why it has captured the interest of so many open source programmers. As part of the successful "in a nutshell" series of books from O'Reilly & Associates, Ruby in a Nutshell is for readers who want a single desktop reference for all their needs.

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. How This Book Is Organized
    2. Conventions Used in This Book
    3. Comments and Questions
    4. Acknowledgments
  3. 1. Introduction
    1. 1.1. Ruby’s Elegance
    2. 1.2. Ruby in Action
  4. 2. Language Basics
    1. 2.1. Command-Line Options
    2. 2.2. Environment Variables
    3. 2.3. Lexical Conventions
      1. 2.3.1. Whitespace
      2. 2.3.2. Line Endings
      3. 2.3.3. Comments
      4. 2.3.4. Identifiers
      5. 2.3.5. Reserved Words
    4. 2.4. Literals
      1. 2.4.1. Numbers
        1. 2.4.1.1. Integers
        2. 2.4.1.2. Floating-point numbers
      2. 2.4.2. Strings
        1. 2.4.2.1. String concatenation
        2. 2.4.2.2. Expression substitution
        3. 2.4.2.3. Backslash notation
        4. 2.4.2.4. General delimited strings
        5. 2.4.2.5. here documents
      3. 2.4.3. Symbols
      4. 2.4.4. Arrays
        1. 2.4.4.1. General delimited string array
      5. 2.4.5. Hashes
      6. 2.4.6. Regular Expressions
        1. 2.4.6.1. Regular-expression modifiers
        2. 2.4.6.2. Regular-expression patterns
    5. 2.5. Variables
    6. 2.6. Operators
      1. 2.6.1. Operator Expressions
        1. 2.6.1.1. Nonmethod operators
        2. 2.6.1.2. Range operators
        3. 2.6.1.3. Logical operators
        4. 2.6.1.4. Ternary operator
        5. 2.6.1.5. defined? operator
    7. 2.7. Methods
      1. Reference Section
      2. 2.7.1. Specifying Blocks with Method Calls
      3. 2.7.2. Singleton Methods
      4. 2.7.3. Method Operations
      5. 2.7.4. Other Method-Related Statements
    8. 2.8. Control Structures
    9. 2.9. Object-Oriented Programming
      1. 2.9.1. Classes and Instances
      2. 2.9.2. Methods
      3. 2.9.3. Singleton Classes
      4. 2.9.4. Modules
      5. 2.9.5. Mix-ins
      6. 2.9.6. Method Visibility
      7. 2.9.7. Object Initialization
      8. 2.9.8. Attributes
      9. 2.9.9. Hooks
    10. 2.10. Security
      1. 2.10.1. Restricted Execution
  5. 3. Built-in Library Reference
    1. 3.1. Predefined Variables
    2. 3.2. Predefined Global Constants
    3. 3.3. Built-in Functions
    4. 3.4. Built-in Library
      1. 3.4.1. Objects
      2. 3.4.2. Strings and Regular Expressions
      3. 3.4.3. Arrays and Hashes
      4. 3.4.4. Numbers
      5. 3.4.5. Operating System Services
      6. 3.4.6. Threads
      7. 3.4.7. Exceptions
      8. 3.4.8. Built-in Exceptions
      9. 3.4.9. Classes and Modules
      10. 3.4.10. Proc Objects and Bindings
      11. 3.4.11. Miscellaneous Classes and Modules
  6. 4. Standard Library Reference
    1. 4.1. Standard Library
      1. 4.1.1. Network
      2. 4.1.2. Operating System Services
      3. 4.1.3. Threads
      4. 4.1.4. Data Persistence
      5. 4.1.5. Numbers
      6. 4.1.6. Design Patterns
      7. 4.1.7. Miscellaneous Libraries
  7. 5. Ruby Tools
    1. 5.1. Standard Tools
      1. 5.1.1. Debugger
      2. 5.1.2. Profiler
      3. 5.1.3. Tracer
      4. 5.1.4. irb
      5. 5.1.5. ruby-mode for Emacs
    2. 5.2. Additional Tools
      1. 5.2.1. ri: Ruby Interactive Reference
      2. 5.2.2. eRuby
    3. 5.3. Ruby Application Archive
  8. 6. Ruby Updates
    1. 6.1. Summary of Changes
    2. 6.2. Changes from 1.6.5 to 1.7.1
    3. 6.3. The Future of Ruby
    4. 6.4. Participate in Ruby
  9. Index
  10. About the Author
  11. Colophon
  12. Copyright

Product information

  • Title: Ruby in a Nutshell
  • Author(s): Yukihiro Matsumoto
  • Release date: November 2001
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596002145