You are previewing Sams Teach Yourself Ruby in 21 Days.
O'Reilly logo
Sams Teach Yourself Ruby in 21 Days

Book Description

Ruby is a high-level, fully object-oriented programming (OOP) language. It is very powerful and relatively easy to learn, read, and maintain.

Sams Teach Yourself Ruby in 21 Days provides the best introduction to this language and addresses one of the key constraints it faces: "The paucity of quality English-language documentation is one of the few things holding Ruby back from widespread adoption," according to Dr. Curtis Clifton of Iowa State University¿s Department of Graduate Computer Science.

Table of Contents

  1. Copyright
  2. About the Lead Author
  3. About the Contributing Authors
  4. Acknowledgments
  5. Tell Us What You Think!
  6. Introduction
  7. The Fundamentals
    1. Getting Started with Ruby
      1. Why Ruby?
      2. Make Sure You Have Ruby
      3. First Steps
      4. Using Ruby Interactively
      5. Summary
      6. Is There Homework in This Class?
    2. Hello, Objects!
      1. What Is an Object?
      2. The First Object: self
      3. The Second Object: other
      4. Classes
      5. Who Is This “self” Anyway?
      6. Name Tags, Not Suitcases
      7. Summary
    3. Containers
      1. A Change in Convention
      2. Some Words About Ambiguity
      3. Back to Business
      4. Strings
      5. Arrays
      6. Hashes
      7. Ranges
      8. Summary
    4. Iteration and Flow Control
      1. Using Iterators
      2. Flow Control
      3. Summary
    5. The Characteristics of Objects
      1. Instance Variables
      2. Global Variables
      3. What to Name Things
    6. Ins and Outs
      1. Streams
      2. What About Memory Space?
      3. Formatted Output
      4. Class Methods
      5. The Command Line
      6. Class Variables
      7. Errors and Exceptions
      8. Summary
    7. Catching Up on Details
      1. Numbers in Ruby
      2. Boolean Logic
      3. Strings and String Literals
      4. Block Scope for Local Variables
      5. Shortcuts and Tricks
      6. Functional and Imperative Styles
      7. Summary
  8. Power Scripting
    1. Pattern Matching
      1. Simple Pattern Matching
      2. Position Anchors
      3. Repetition
      4. Grouping
      5. Switches
      6. Some Container Methods That Use Regexes
      7. Regexes and Matches as Objects
      8. Summary
    2. Inheritance and Modules
      1. Organizing Organization
      2. The Make-Up of Ruby Classes: Some “What” and a Little “How”
      3. Fiddling with Inheritance
      4. Play It Again, Ruby: Another Method Call Example
      5. Modules
      6. Resolving Method Ambiguities
      7. Summary
    3. Program File Layout, Program Design, and the General Case
      1. Program and File Interaction
      2. Runtime Extension of Ruby's World: require
      3. The Argument to require
      4. Compiled Extensions
      5. Examining the Ruby Installation
      6. Abstraction and the General Case
      7. Summary
    4. Modules and Classes in Depth
      1. Designing Modules and Classes for Clarity and Reuse
      2. Embedded Modules and Namespace Management
      3. Class-Module Distribution Across Program Files
      4. Overriding Methods
      5. Summary
    5. An Introduction to Recursion
      1. The Canonical Starting Point: Factorials
      2. Efficiency Concerns
      3. The Towers of Hanoi
      4. Summary
    6. Mastering the Operating System
      1. Motivation
      2. Portability Notes
      3. Gathering Information
      4. Treating Programs as Functions
      5. Extended Conversations
      6. The Art of Instant Reproduction
      7. How to Control Your Children
      8. Summary
    7. Arguments, Blocks, and Procs
      1. Life Without Iterators
      2. Writing Iterator Methods
      3. Other Uses for Blocks
      4. Summary
  9. Making It Work for You
    1. Toward Habitable Interfaces
      1. Interface Size and Intuitiveness
      2. An IntegerMatrix Class
      3. Summary
    2. Putting It Together (Part I)
      1. The Unjumbler
      2. Notes on Language Enhancement
      3. An Interactive Process Killer
      4. Summary
    3. Ruby/Tk
      1. What Is Tk?
      2. Our First Tk Application
      3. Geometry Managers
      4. Entry Widgets and Buttons
      5. Some Other Widgets
      6. More Complex Coding
      7. Summary
    4. Ruby/Gtk
      1. Installation under Unix
      2. Installation under Windows
      3. First Ruby/Gtk Scripts
      4. Simple Widget Layout
      5. Modular Design for Multiple Windows
      6. More Widget Types
      7. A Full Ruby/Gtk Application
      8. Summary
    5. Some Advanced Topics (That Aren't So Hard)
      1. Sockets
      2. Threads
      3. Summary
    6. Working with the Web
      1. Static Content Versus Dynamic Content
      2. Server-Side Versus Client-Side
      3. Privileges at the Server
      4. Configuring Apache: httpd.conf
      5. Test Drives
      6. Know Thy Client
      7. Object-Oriented CGI Support
      8. Embedded Ruby
      9. Summary
    7. Putting It Together (Part II)
      1. Binary Decision Trees
      2. Tk-Based Peer Chat
      3. Summary
  10. Appendices
    1. irb Results
    2. Installation Help
      1. Unix
      2. Microsoft Windows
    3. Debugging, With and Without a Debugger
      1. Stack Traces
      2. Inline Diagnostics
      3. The Built-In Debugger
    4. Essential Vocabulary
      1. Standard Method Names
      2. Standard Class and Module Names