Beginning Ruby: From Novice to Professional

Book description

Based on the best-selling first edition, Beginning Ruby: From Novice to Professional, Second Edition is the leading guide for every type of reader who wants to learn Ruby from the ground up.

Table of contents

  1. Copyright
  2. Foreword
  3. About the Author
  4. About the Technical Reviewer
  5. Acknowledgments
  6. Introduction
  7. 1. Foundations and Scaffolding
    1. 1. Let's Get It Started: Installing Ruby
      1. 1.1. Installing Ruby
        1. 1.1.1. Windows
        2. 1.1.2. Apple Mac OS X
          1. 1.1.2.1. Testing for a Preinstalled Version of Ruby
          2. 1.1.2.2. Installing Ruby on OS X
          3. 1.1.2.3. Installing Ruby from Source on Mac OS X
        3. 1.1.3. Linux
          1. 1.1.3.1. Checking If Ruby Is Installed on Linux
          2. 1.1.3.2. Installing Ruby with a Package Manager
          3. 1.1.3.3. Installing Ruby from Source Code
        4. 1.1.4. Other Platforms
      2. 1.2. Summary
    2. 2. Programming == Joy: A Whistle-Stop Tour of Ruby and Object Orientation
      1. 2.1. Baby Steps
        1. 2.1.1. irb: Interactive Ruby
        2. 2.1.2. Ruby Is English for Computers
        3. 2.1.3. Why Ruby Makes a Great Programming Language
        4. 2.1.4. Trails for the Mind
      2. 2.2. Turning Ideas into Ruby Code
        1. 2.2.1. How Ruby Understands Concepts with Objects and Classes
        2. 2.2.2. The Making of a Man
        3. 2.2.3. Basic Variables
        4. 2.2.4. From People to Pets
          1. 2.2.4.1. Structuring Your Pets Logically
          2. 2.2.4.2. Controlling Your Pets
      3. 2.3. Everything Is an Object
        1. 2.3.1. Kernel Methods
        2. 2.3.2. Passing Data to Methods
        3. 2.3.3. Using the Methods of the String Class
      4. 2.4. Using Ruby Without Object Orientation
      5. 2.5. Summary
    3. 3. Ruby's Building Blocks: Data, Expressions, and Flow Control
      1. 3.1. Numbers and Expressions
        1. 3.1.1. Basic Expressions
        2. 3.1.2. Variables
        3. 3.1.3. Comparison Operators and Expressions
        4. 3.1.4. Looping Through Numbers with Blocks and Iterators
        5. 3.1.5. Floating Point Numbers
        6. 3.1.6. Constants
      2. 3.2. Text and Strings
        1. 3.2.1. String Literals
        2. 3.2.2. String Expressions
        3. 3.2.3. Interpolation
        4. 3.2.4. String Methods
        5. 3.2.5. Regular Expressions and String Manipulation
          1. 3.2.5.1. Substitutions
          2. 3.2.5.2. Iteration with a Regular Expression
          3. 3.2.5.3. Matching
      3. 3.3. Arrays and Lists
        1. 3.3.1. Basic Arrays
        2. 3.3.2. Splitting Strings into Arrays
        3. 3.3.3. Array Iteration
        4. 3.3.4. Other Array Methods
          1. 3.3.4.1. Array Addition and Concatenation
          2. 3.3.4.2. Array Subtraction and Difference
          3. 3.3.4.3. Checking for an Empty Array
          4. 3.3.4.4. Checking an Array for a Certain Item
          5. 3.3.4.5. Accessing the First and Last Elements of the Array
          6. 3.3.4.6. Reversing the Order of the Array's Elements
      4. 3.4. Hashes
        1. 3.4.1. Basic Hash Methods
          1. 3.4.1.1. Iterating Through Hash Elements
          2. 3.4.1.2. Retrieving Keys
          3. 3.4.1.3. Deleting Hash Elements
          4. 3.4.1.4. Deleting Hash Elements Conditionally
        2. 3.4.2. Hashes Within Hashes
      5. 3.5. Flow Control
        1. 3.5.1. if and unless
        2. 3.5.2. ?, the Ternary Operator
        3. 3.5.3. elsif and case
        4. 3.5.4. while and until
        5. 3.5.5. Code Blocks
      6. 3.6. Other Useful Building Blocks
        1. 3.6.1. Dates and Times
        2. 3.6.2. Large Numbers
        3. 3.6.3. Ranges
        4. 3.6.4. Symbols
        5. 3.6.5. Converting Objects to Other Classes
      7. 3.7. Summary
    4. 4. Developing Your First Ruby Application
      1. 4.1. Working with Source Code Files
        1. 4.1.1. Creating a Test File
          1. 4.1.1.1. Windows
          2. 4.1.1.2. Mac OS X
          3. 4.1.1.3. Linux
        2. 4.1.2. The Test Source Code File
        3. 4.1.3. Running Your Source Code
          1. 4.1.3.1. Windows
          2. 4.1.3.2. Mac OS X
          3. 4.1.3.3. Linux and Other UNIX-Based Systems
      2. 4.2. Our Application: A Text Analyzer
        1. 4.2.1. Required Basic Features
        2. 4.2.2. Building the Basic Application
        3. 4.2.3. Obtaining Some Dummy Text
        4. 4.2.4. Loading Text Files and Counting Lines
        5. 4.2.5. Counting Characters
        6. 4.2.6. Counting Words
        7. 4.2.7. Counting Sentences and Paragraphs
        8. 4.2.8. Calculating Averages
        9. 4.2.9. The Source Code So Far
      3. 4.3. Adding Extra Features
        1. 4.3.1. Percentage of "Useful" Words
        2. 4.3.2. Summarizing by Finding "Interesting" Sentences
        3. 4.3.3. Analyzing Files Other Than text.txt
      4. 4.4. The Completed Program
      5. 4.5. Summary
    5. 5. The Ruby Ecosystem
      1. 5.1. Ruby's History
        1. 5.1.1. The Land of the Rising Sun
        2. 5.1.2. Ruby's Influences
        3. 5.1.3. Go West
        4. 5.1.4. Alternative Ruby Implementations
      2. 5.2. Ruby on Rails
        1. 5.2.1. Why Rails Came into Existence
        2. 5.2.2. How the Web (2.0) Was Won
      3. 5.3. The Open Source Culture
        1. 5.3.1. What Is Open Source?
      4. 5.4. Where and How to Get Help
        1. 5.4.1. Mailing Lists
        2. 5.4.2. Internet Relay Chat (IRC)
        3. 5.4.3. Documentation
        4. 5.4.4. Forums
      5. 5.5. Joining the Community
        1. 5.5.1. Give Help to Others
        2. 5.5.2. Contribute Code
        3. 5.5.3. Blogs
        4. 5.5.4. Events
      6. 5.6. Summary
  8. 2. The Core of Ruby
    1. 6. Classes, Objects, and Modules
      1. 6.1. Why Use Object Orientation?
      2. 6.2. Object-Orientation Basics
        1. 6.2.1. Local, Global, Object, and Class Variables
          1. 6.2.1.1. Local Variables
          2. 6.2.1.2. Global Variables
          3. 6.2.1.3. Object Variables
          4. 6.2.1.4. Class Variables
        2. 6.2.2. Class Methods vs. Object Methods
        3. 6.2.3. Inheritance
        4. 6.2.4. Overriding Existing Methods
        5. 6.2.5. Reflection and Discovering an Object's Methods
        6. 6.2.6. Encapsulation
        7. 6.2.7. Polymorphism
        8. 6.2.8. Nested Classes
        9. 6.2.9. The Scope of Constants
      3. 6.3. Modules, Namespaces, and Mix-Ins
        1. 6.3.1. Namespaces
        2. 6.3.2. Mix-Ins
          1. 6.3.2.1. Enumerable
          2. 6.3.2.2. Comparable
          3. 6.3.2.3. Using Mix-Ins with Namespaces and Classes
      4. 6.4. Building a Dungeon Text Adventure with Objects
        1. 6.4.1. Dungeon Concepts
        2. 6.4.2. Creating the Initial Classes
        3. 6.4.3. Structs: Quick and Easy Data Classes
        4. 6.4.4. Creating Rooms
        5. 6.4.5. Making the Dungeon Work
      5. 6.5. Summary
    2. 7. Projects and Libraries
      1. 7.1. Projects and Using Code from Other Files
        1. 7.1.1. Basic File Inclusion
        2. 7.1.2. Inclusions from Other Directories
        3. 7.1.3. Logic and Including Code
        4. 7.1.4. Nested Inclusions
      2. 7.2. Libraries
        1. 7.2.1. The Standard Libraries
          1. 7.2.1.1. net/http
          2. 7.2.1.2. OpenStruct
        2. 7.2.2. RubyGems
          1. 7.2.2.1. Installing RubyGems on Ruby 1.8
            1. 7.2.2.1.1. Windows
            2. 7.2.2.1.2. Linux and Other Unix Distributions
          2. 7.2.2.2. Finding Gems
          3. 7.2.2.3. Installing a Simple Gem
          4. 7.2.2.4. Using Gems
          5. 7.2.2.5. Installing a More Complex Gem
          6. 7.2.2.6. Upgrading and Uninstalling Gems
          7. 7.2.2.7. Creating Your Own Gems
      3. 7.3. Summary
    3. 8. Documentation, Error Handling, Debugging, and Testing
      1. 8.1. Documentation
        1. 8.1.1. Generating Documentation with RDoc
        2. 8.1.2. RDoc Techniques
          1. 8.1.2.1. Producing Documentation for an Entire Project
          2. 8.1.2.2. Basic Formatting
          3. 8.1.2.3. Modifiers and Options
            1. 8.1.2.3.1. :nodoc: Modifier
            2. 8.1.2.3.2. Turning RDoc Processing On and Off
            3. 8.1.2.3.3. Command-Line Options
      2. 8.2. Debugging and Errors
        1. 8.2.1. Exceptions and Error Handling
          1. 8.2.1.1. Raising Exceptions
          2. 8.2.1.2. Handling Exceptions
          3. 8.2.1.3. Handling Passed Exceptions
        2. 8.2.2. Catch and Throw
        3. 8.2.3. The Ruby Debugger
      3. 8.3. Testing
        1. 8.3.1. The Philosophy of Test-Driven Development
        2. 8.3.2. Unit Testing
        3. 8.3.3. More Test::Unit Assertions
      4. 8.4. Benchmarking and Profiling
        1. 8.4.1. Simple Benchmarking
        2. 8.4.2. Profiling
      5. 8.5. Summary
    4. 9. Files and Databases
      1. 9.1. Input and Output
        1. 9.1.1. Keyboard Input
        2. 9.1.2. File I/O
          1. 9.1.2.1. Opening and Reading Files
          2. 9.1.2.2. More File-Reading Techniques
          3. 9.1.2.3. Your Position Within a File
          4. 9.1.2.4. Writing to Files
          5. 9.1.2.5. Character Sets and Encodings (Ruby 1.9 and Above Only)
          6. 9.1.2.6. Renaming and Deleting Files
          7. 9.1.2.7. File Operations
            1. 9.1.2.7.1. Creating Filenames Platform-Independently
            2. 9.1.2.7.2. Seeking
            3. 9.1.2.7.3. Finding Out When a File Was Last Modified
            4. 9.1.2.7.4. Checking Whether a File Exists
            5. 9.1.2.7.5. Getting the Size of a File
            6. 9.1.2.7.6. How to Know When You're at the End of a File
          8. 9.1.2.8. Directories
            1. 9.1.2.8.1. Navigating Through Directories
            2. 9.1.2.8.2. Creating a Directory
            3. 9.1.2.8.3. Deleting a Directory
            4. 9.1.2.8.4. Creating Files in the Temporary Directory
      2. 9.2. Basic Databases
        1. 9.2.1. Text File Databases
          1. 9.2.1.1. Reading and Searching CSV Data
          2. 9.2.1.2. Saving Data Back to the CSV File
        2. 9.2.2. Storing Objects and Data Structures
          1. 9.2.2.1. PStore
          2. 9.2.2.2. YAML
      3. 9.3. Relational Databases and SQL
        1. 9.3.1. Relational Database Concepts
        2. 9.3.2. The Big Four: MySQL, PostgreSQL, Oracle, and SQLite
        3. 9.3.3. Installing SQLite
        4. 9.3.4. A Crash Course in Basic Database Actions and SQL
          1. 9.3.4.1. What Is SQL?
          2. 9.3.4.2. CREATE TABLE
          3. 9.3.4.3. INSERT INTO
          4. 9.3.4.4. SELECT
          5. 9.3.4.5. DELETE
          6. 9.3.4.6. UPDATE
        5. 9.3.5. Using SQLite with Ruby
        6. 9.3.6. Connecting to Other Database Systems
          1. 9.3.6.1. MySQL
          2. 9.3.6.2. PostgreSQL
          3. 9.3.6.3. Oracle
          4. 9.3.6.4. Microsoft SQL Server
          5. 9.3.6.5. DBI: A Generic Database Connectivity Library
        7. 9.3.7. ActiveRecord: A Sneak Peek
      4. 9.4. Summary
    5. 10. Deploying Ruby Applications and Libraries
      1. 10.1. Distributing Basic Ruby Programs
        1. 10.1.1. The Shebang Line
        2. 10.1.2. Associated File Types in Windows
        3. 10.1.3. "Compiling" Ruby
          1. 10.1.3.1. RubyScript2Exe
          2. 10.1.3.2. Platypus
      2. 10.2. Detecting Ruby's Runtime Environment
        1. 10.2.1. Easy OS Detection with RUBY_PLATFORM
        2. 10.2.2. Environment Variables
        3. 10.2.3. Accessing Command-Line Arguments
      3. 10.3. Distributing and Releasing Ruby Libraries As Gems
        1. 10.3.1. Creating a Gem
          1. 10.3.1.1. Structuring Your Files
          2. 10.3.1.2. Creating a Specification File
          3. 10.3.1.3. Building the Gem
          4. 10.3.1.4. Easier Gem Creation
        2. 10.3.2. Distributing a Gem
        3. 10.3.3. RubyForge
        4. 10.3.4. GitHub
      4. 10.4. Deploying Ruby Applications As Remote Services
        1. 10.4.1. CGI Scripts
          1. 10.4.1.1. A Basic CGI Script
          2. 10.4.1.2. Accepting CGI Variables
        2. 10.4.2. Generic HTTP Servers
          1. 10.4.2.1. WEBrick
          2. 10.4.2.2. Mongrel
        3. 10.4.3. Remote Procedure Calls
          1. 10.4.3.1. XML-RPC
            1. 10.4.3.1.1. Calling an XML-RPC–Enabled Method
            2. 10.4.3.1.2. Making an XML-RPC–Enabled Program
          2. 10.4.3.2. DRb
      5. 10.5. Summary
    6. 11. Advanced Ruby Features
      1. 11.1. Dynamic Code Execution
        1. 11.1.1. Bindings
        2. 11.1.2. Other Forms of eval
        3. 11.1.3. Creating Your Own Version of attr_accessor
      2. 11.2. Running Other Programs from Ruby
        1. 11.2.1. Getting Results from Other Programs
        2. 11.2.2. Transferring Execution to Another Program
        3. 11.2.3. Running Two Programs at the Same Time
        4. 11.2.4. Interacting with Another Program
      3. 11.3. Safely Handling Data and Dangerous Methods
        1. 11.3.1. Tainted Data and Objects
        2. 11.3.2. Safe Levels
      4. 11.4. Working with Microsoft Windows
        1. 11.4.1. Using the Windows API
        2. 11.4.2. Controlling Windows Programs
      5. 11.5. Threads
        1. 11.5.1. Basic Ruby Threads in Action
        2. 11.5.2. Advanced Thread Operations
          1. 11.5.2.1. Waiting for Threads to Finish Redux
          2. 11.5.2.2. Getting a List of All Threads
          3. 11.5.2.3. Thread Operations from Within Threads Themselves
      6. 11.6. Fibers
        1. 11.6.1. A Fiber in Action
        2. 11.6.2. Passing Data to a Fiber
        3. 11.6.3. Why Fibers?
      7. 11.7. RubyInline
        1. 11.7.1. Why Use C As an Inline Language?
        2. 11.7.2. Creating a Basic Method or Function
        3. 11.7.3. Benchmarking C vs. Ruby
      8. 11.8. Unicode, Character Encodings, and UTF-8 Support
        1. 11.8.1. Ruby 1.8's Workarounds
        2. 11.8.2. Ruby 1.9's Character Encoding Support
          1. 11.8.2.1. Strings
          2. 11.8.2.2. Source Code
      9. 11.9. Summary
    7. 12. Tying It Together: Developing a Larger Ruby Application
      1. 12.1. Let's Build a Bot
        1. 12.1.1. What Is a Bot?
        2. 12.1.2. Why a Bot?
        3. 12.1.3. How?
      2. 12.2. Creating a Text Processing Tools Library
        1. 12.2.1. Building the WordPlay Library
          1. 12.2.1.1. Splitting Text into Sentences
          2. 12.2.1.2. Splitting Sentences into Words
          3. 12.2.1.3. Word Matching
          4. 12.2.1.4. Switching Subject and Object Pronouns
        2. 12.2.2. Testing the Library
          1. 12.2.2.1. Testing Sentence Separation
          2. 12.2.2.2. Testing Word Separation
          3. 12.2.2.3. Testing Best Sentence Choice
          4. 12.2.2.4. Testing Pronoun Switches
        3. 12.2.3. WordPlay's Source Code
          1. 12.2.3.1. wordplay.rb
          2. 12.2.3.2. test_wordplay.rb
      3. 12.3. Building the Bot's Core
        1. 12.3.1. The Program's Life Cycle and Parts
        2. 12.3.2. Bot Data
          1. 12.3.2.1. The Data Structure
          2. 12.3.2.2. Storing the Data Externally
        3. 12.3.3. Constructing the Bot Class and Data Loader
        4. 12.3.4. The response_to Method
          1. 12.3.4.1. Accepting Input and Performing Substitutions
          2. 12.3.4.2. Choosing the Best Sentence
          3. 12.3.4.3. Looking for Matching Phrases
          4. 12.3.4.4. Putting Together the Final Phrase
        5. 12.3.5. Playing with the Bot
          1. 12.3.5.1. Fred: Your Bot's Personality
          2. 12.3.5.2. The First Real Conversation
      4. 12.4. Main Bot Code Listings
        1. 12.4.1. bot.rb
        2. 12.4.2. basic_client.rb
      5. 12.5. Extending the Bot
        1. 12.5.1. Using Text Files As a Source of Conversation
        2. 12.5.2. Connecting the Bot to the Web
        3. 12.5.3. Bot-to-Bot Conversations
      6. 12.6. Summary
  9. 3. Ruby Online
    1. 13. Web Application Frameworks: Rails, Sinatra, and Ramaze
      1. 13.1. Background
        1. 13.1.1. The Limitations and Benefits of Our Approach
        2. 13.1.2. Pros and Cons of the Frameworks Covered
        3. 13.1.3. Merb: The Missing Framework
      2. 13.2. Rails: Ruby's Killer App
        1. 13.2.1. What Is Rails and Why Use It?
        2. 13.2.2. Installing Rails
          1. 13.2.2.1. Database Considerations
        3. 13.2.3. Building a Basic Rails Application
          1. 13.2.3.1. Creating a Blank Rails Application
            1. 13.2.3.1.1. The rails Command-Line Tool
          2. 13.2.3.2. Files and Directories Within a Rails Application
          3. 13.2.3.3. Database Configuration
          4. 13.2.3.4. Using Scaffolding
          5. 13.2.3.5. Database Migrations
          6. 13.2.3.6. Running the Basic, Scaffolded App
        4. 13.2.4. Controllers and Views
          1. 13.2.4.1. Controller Actions
          2. 13.2.4.2. Views and Embedded Ruby (ERB)
          3. 13.2.4.3. Creating a New Action and View
        5. 13.2.5. Models and Relationships
        6. 13.2.6. Sessions and Filters
        7. 13.2.7. Other Features
          1. 13.2.7.1. Layouts
          2. 13.2.7.2. Testing
          3. 13.2.7.3. Plugins
        8. 13.2.8. Where to Go Next: References, Books, and Example Apps
          1. 13.2.8.1. Reference Sites and Tutorials
          2. 13.2.8.2. Rails Books
          3. 13.2.8.3. Open Source Rails Applications
      3. 13.3. Sinatra: The Framework for Lightweight, Simple Web Applications
        1. 13.3.1. The Extreme Simplicity of Sinatra
        2. 13.3.2. General URL Routing and Parameter Matching
        3. 13.3.3. Views, Templates, and Static Files
          1. 13.3.3.1. Inline and In-File Templates
          2. 13.3.3.2. Layouts
          3. 13.3.3.3. External Templates and Layouts
          4. 13.3.3.4. Static Files
        4. 13.3.4. Request Flow Control
          1. 13.3.4.1. Redirection
          2. 13.3.4.2. Halting
          3. 13.3.4.3. Error Handling
        5. 13.3.5. Further Resources
      4. 13.4. Ramaze: A Lightweight, MVC-Focused Web Application Framework
        1. 13.4.1. Generating a Bare Ramaze App
        2. 13.4.2. Application Structure and Customization
          1. 13.4.2.1. Key Files and Loading Strategy
          2. 13.4.2.2. Controllers
            1. 13.4.2.2.1. The Main Controller
            2. 13.4.2.2.2. Creating a Controller
            3. 13.4.2.2.3. Parameters
          3. 13.4.2.3. Templates and Views
            1. 13.4.2.3.1. Template Engines and Ezamar
            2. 13.4.2.3.2. Views for Controller Methods
            3. 13.4.2.3.3. Passing Data from Controllers to Views
          4. 13.4.2.4. Models
            1. 13.4.2.4.1. Creating a Basic Model
            2. 13.4.2.4.2. Using ActiveRecord with Ramaze
        3. 13.4.3. Single-File Applications
        4. 13.4.4. Further Resources
      5. 13.5. Summary
    2. 14. Ruby and the Internet
      1. 14.1. HTTP and the Web
        1. 14.1.1. Downloading Web Pages
          1. 14.1.1.1. The net/http Library
            1. 14.1.1.1.1. Checking for Errors and Redirects
            2. 14.1.1.1.2. Basic Authentication
            3. 14.1.1.1.3. Posting Form Data
            4. 14.1.1.1.4. Using HTTP Proxies
            5. 14.1.1.1.5. Secure HTTP with HTTPS
          2. 14.1.1.2. The open-uri Library
        2. 14.1.2. Generating Web Pages and HTML
          1. 14.1.2.1. Markaby: Markup As Ruby
          2. 14.1.2.2. RedCloth
        3. 14.1.3. Processing Web Content
          1. 14.1.3.1. Parsing HTML with Hpricot
          2. 14.1.3.2. Parsing XML with REXML
          3. 14.1.3.3. Parsing Web Feeds with Feedzirra
      2. 14.2. E-Mail
        1. 14.2.1. Receiving Mail with POP3
        2. 14.2.2. Sending Mail with SMTP
        3. 14.2.3. Sending Mail with ActionMailer
      3. 14.3. File Transfers with FTP
        1. 14.3.1. Connection and Basic FTP Actions
        2. 14.3.2. Downloading Files
        3. 14.3.3. Uploading Files
      4. 14.4. Summary
    3. 15. Networking, Sockets, and Daemons
      1. 15.1. Networking Concepts
        1. 15.1.1. TCP and UDP
        2. 15.1.2. IP Addresses and DNS
      2. 15.2. Basic Network Operations
        1. 15.2.1. Checking Machine and Service Availability
        2. 15.2.2. Performing DNS Queries
        3. 15.2.3. Connecting to a TCP Server Directly
      3. 15.3. Servers and Clients
        1. 15.3.1. UDP Client and Server
        2. 15.3.2. Building a Simple TCP Server
        3. 15.3.3. Multi-Client TCP Servers
        4. 15.3.4. GServer
        5. 15.3.5. A GServer-Based Chat Server
        6. 15.3.6. Web/HTTP Servers
        7. 15.3.7. Daemon Processes
          1. 15.3.7.1. Basic Daemon Creation
          2. 15.3.7.2. Using the daemons Library for More Powerful Daemons
      4. 15.4. Summary
    4. 16. GUI-Based Desktop Application Development
      1. 16.1. An Overview of GUI App Development in Ruby
        1. 16.1.1. Ruby GUI Development Considerations
        2. 16.1.2. Our Focus: Shoes
      2. 16.2. Shoes: An Original Ruby-Based GUI Development Toolkit
        1. 16.2.1. Installation
        2. 16.2.2. A Barebones Application
        3. 16.2.3. Layouts, Stacks, and Flows
        4. 16.2.4. Controls and Elements
          1. 16.2.4.1. Shapes and Colors
          2. 16.2.4.2. Color
          3. 16.2.4.3. Text
          4. 16.2.4.4. Backgrounds
          5. 16.2.4.5. Images
          6. 16.2.4.6. Miscellaneous User Interface Elements
        5. 16.2.5. Events and Element Methods
        6. 16.2.6. Miscellaneous Functionality
          1. 16.2.6.1. Mouse and Keyboard Events
          2. 16.2.6.2. Dialogs
          3. 16.2.6.3. Using Other Ruby Code Within Shoes Applications
          4. 16.2.6.4. Packaging Applications for Distribution
        7. 16.2.7. Further Resources
      3. 16.3. Alternative GUI Development Options
        1. 16.3.1. wxRuby
        2. 16.3.2. Ruby-GNOME2
        3. 16.3.3. MacRuby and Cocoa
        4. 16.3.4. JRuby and Monkeybars
        5. 16.3.5. QtRuby
        6. 16.3.6. FXRuby
      4. 16.4. Summary
    5. 17. Useful Ruby Libraries and Gems
      1. 17.1. abbrev
        1. 17.1.1. Installation
        2. 17.1.2. Examples
        3. 17.1.3. Further Information
      2. 17.2. base64
        1. 17.2.1. Installation
        2. 17.2.2. Examples
          1. 17.2.2.1. Converting Binary Data to Base64
          2. 17.2.2.2. Converting Base64 Data to Binary Data
          3. 17.2.2.3. Using Compression to Make Base64 Efficient
        3. 17.2.3. Further Information
      3. 17.3. BlueCloth
        1. 17.3.1. Installation
        2. 17.3.2. Examples
        3. 17.3.3. Further Information
      4. 17.4. cgi
        1. 17.4.1. Installation
        2. 17.4.2. Examples
          1. 17.4.2.1. A Basic CGI Script
          2. 17.4.2.2. Accepting CGI Variables
          3. 17.4.2.3. Cookies
          4. 17.4.2.4. Sessions
        3. 17.4.3. Further Information
      5. 17.5. chronic
        1. 17.5.1. Installation
        2. 17.5.2. Examples
        3. 17.5.3. Further Information
      6. 17.6. Digest
        1. 17.6.1. Installation
        2. 17.6.2. Examples
        3. 17.6.3. Further Information
      7. 17.7. English
        1. 17.7.1. Installation
        2. 17.7.2. Examples
        3. 17.7.3. Further Information
      8. 17.8. ERB
        1. 17.8.1. Installation
        2. 17.8.2. Examples
          1. 17.8.2.1. Basic Templates and Rendering
          2. 17.8.2.2. Accessing Outside Variables
          3. 17.8.2.3. Safe Levels
        3. 17.8.3. Further Information
      9. 17.9. FasterCSV
        1. 17.9.1. Installation
        2. 17.9.2. Examples
          1. 17.9.2.1. Parsing a String Line by Line
          2. 17.9.2.2. Parsing a String to an Array of Arrays
          3. 17.9.2.3. Parsing CSV Data from a File Line by Line
          4. 17.9.2.4. Parsing a Whole CSV File to an Array of Arrays
          5. 17.9.2.5. Generating CSV Data
          6. 17.9.2.6. FasterCSV Tables
        3. 17.9.3. Further Information
      10. 17.10. HTTParty
        1. 17.10.1. Installation
        2. 17.10.2. Examples
        3. 17.10.3. Further Information
      11. 17.11. logger
        1. 17.11.1. Installation
        2. 17.11.2. Examples
          1. 17.11.2.1. Setting Up a Logger
          2. 17.11.2.2. Logging Levels
          3. 17.11.2.3. Logging Messages
          4. 17.11.2.4. Closing a Logger
        3. 17.11.3. Further Information
      12. 17.12. Nokogiri
        1. 17.12.1. Installation
        2. 17.12.2. Examples
        3. 17.12.3. Further Information
      13. 17.13. pp
        1. 17.13.1. Installation
        2. 17.13.2. Examples
        3. 17.13.3. Further Information
      14. 17.14. RedCloth
        1. 17.14.1. Installation
        2. 17.14.2. Examples
        3. 17.14.3. Further Information
      15. 17.15. StringScanner
        1. 17.15.1. Installation
        2. 17.15.2. Examples
        3. 17.15.3. Further Information
      16. 17.16. tempfile
        1. 17.16.1. Installation
        2. 17.16.2. Examples
        3. 17.16.3. Further Information
      17. 17.17. uri
        1. 17.17.1. Installation
        2. 17.17.2. Examples
          1. 17.17.2.1. Extracting URLs from Text
          2. 17.17.2.2. Parsing URLs
          3. 17.17.2.3. Creating URLs
        3. 17.17.3. Further Information
      18. 17.18. zlib
        1. 17.18.1. Installation
        2. 17.18.2. Examples
        3. 17.18.3. Further Information
  10. A. Ruby Primer and Review for Developers
    1. A.1. The Basics
      1. A.1.1. Definition and Concepts
      2. A.1.2. The Ruby Interpreter and Running Ruby Code
      3. A.1.3. Interactive Ruby
    2. A.2. Expressions, Logic, and Flow Control
      1. A.2.1. Basic Expressions
      2. A.2.2. Class Mismatches
      3. A.2.3. Comparison Expressions
      4. A.2.4. Flow
        1. A.2.4.1. Branching and Conditional Execution
        2. A.2.4.2. The Ternary Operator (Conditional Expressions)
        3. A.2.4.3. Loops
    3. A.3. Object Orientation
      1. A.3.1. Objects
      2. A.3.2. Classes and Methods
      3. A.3.3. Reflection
      4. A.3.4. Reopening Classes
      5. A.3.5. Method Visibility
    4. A.4. Data
      1. A.4.1. Strings
      2. A.4.2. Regular Expressions
      3. A.4.3. Numbers
      4. A.4.4. Arrays
      5. A.4.5. Hashes (Associative Arrays)
      6. A.4.6. Complex Structures
    5. A.5. Input/Output
      1. A.5.1. Files
      2. A.5.2. Databases
      3. A.5.3. Web Access
    6. A.6. Libraries
      1. A.6.1. File Organization
      2. A.6.2. Packaging
  11. B. Ruby Reference
    1. B.1. Useful Classes and Methods
      1. B.1.1. Array
      2. B.1.2. Bignum and Fixnum
        1. B.1.2.1. Arithmetic Methods
        2. B.1.2.2. Bitwise Methods
      3. B.1.3. Enumerable
      4. B.1.4. Float
      5. B.1.5. Hash
      6. B.1.6. Integer
      7. B.1.7. Numeric
      8. B.1.8. Object
      9. B.1.9. String
    2. B.2. Regular Expression Syntax
      1. B.2.1. Regular Expression Options
      2. B.2.2. Special Characters and Formations
      3. B.2.3. Character and Sub-Expression Suffixes
    3. B.3. Exception Classes
    4. B.4. Special Variables
    5. B.5. Ruby License
  12. C. Useful Resources
    1. C.1. References
      1. C.1.1. Ruby
      2. C.1.2. Ruby on Rails
      3. C.1.3. Other Web Application Frameworks
    2. C.2. Blogs
      1. C.2.1. Aggregators and Community Blogs
      2. C.2.2. Personal Blogs
    3. C.3. Forums and Newsgroups
    4. C.4. Mailing Lists
    5. C.5. Real-Time Chat
    6. C.6. Tutorials and Guides
      1. C.6.1. Installation
        1. C.6.1.1. Linux
        2. C.6.1.2. Mac OS X
        3. C.6.1.3. Other Platforms
      2. C.6.2. General Ruby Tutorials
      3. C.6.3. Ruby on Rails
      4. C.6.4. Testing
      5. C.6.5. Other

Product information

  • Title: Beginning Ruby: From Novice to Professional
  • Author(s):
  • Release date: July 2009
  • Publisher(s): Apress
  • ISBN: 9781430223634