You don't have to know everything about a car to drive one, and you don't need to know everything about Ruby to start programming with it. Written for both experienced and new programmers alike, Learning Ruby is a just-get-in-and-drive book -- a hands-on tutorial that offers lots of Ruby programs and lets you know how and why they work, just enough to get you rolling down the road.
Interest in Ruby stems from the popularity of Rails, the web development framework that's attracting new devotees and refugees from Java and PHP. But there are plenty of other uses for this versatile language. The best way to learn is to just try the code! You'll find examples on nearly every page of this book that you can imitate and hack. Briefly, this book:
* Outlines many of the most important features of Ruby
* Demonstrates how to use conditionals, and how to manipulate strings in Ruby. Includes a section on regular expressions
* Describes how to use operators, basic math, functions from the Math module, rational numbers, etc.
* Talks you through Ruby arrays, and demonstrates hashes in detail
* Explains how to process files with Ruby
* Discusses Ruby classes and modules (mixins) in detail, including a brief introduction to object-oriented programming (OOP)
* Introduces processing XML, the Tk toolkit, RubyGems, reflection, RDoc, embedded Ruby, metaprogramming, exception handling, and other topics
* Acquaints you with some of the essentials of Rails, and includes a short Rails tutorial.
Each chapter concludes with a set of review questions, and appendices provide you with a glossary of terms related to Ruby programming, plus reference material from the book in one convenient location. If you want to take Ruby out for a drive, Learning Ruby holds the keys.
Sprache
Verlagsort
Illustrationen
Maße
Höhe: 232 mm
Breite: 178 mm
ISBN-13
978-0-596-52986-4 (9780596529864)
Schweitzer Klassifikation
Michael Fitzgerald is principal of Wy'east Communications, an XML consultancy. He is the author of Learning XSLT and XML Hacks. He is also the author of Building B2B Applications with XML and XSL Essentials, both published by John Wiley & Sons. Michael is a regular contributor to XML.com.
Inhaltsverzeichnis
Preface
1. Ruby Basics
Hello, Matz
Interactive Ruby
Resources
Installing Ruby
Permission Denied
Associating File Types on Windows
Review Questions
2. A Quick Tour of Ruby
Ruby Is Object-Oriented
Ruby's Reserved Words
Comments
Variables
Strings
Numbers and Operators
Conditional Statements
Arrays and Hashes
Methods
Blocks
Symbols
Exception Handling
Ruby Documentation
Review Questions
3. Conditional Love
The if Statement
The case Statement
The while Loop
The loop Method
The for loop
Execution Before or After a Program
Review Questions
4. Strings
Creating Strings
Concatenating Strings
Accessing Strings
Comparing Strings
Manipulating Strings
Case Conversion
Managing Whitespace, etc.
Incrementing Strings
Converting Strings
Regular Expressions
1.9 and Beyond
Review Questions
5. Math
Class Hierarchy and Included Modules
Converting Numbers
Basic Math Operations
Ranges
Inquiring About Numbers
More Math Methods
Math Functions
Rational Numbers
Prime Numbers
Review Questions
6. Arrays
Creating Arrays
Accessing Elements
Concatenation
Set Operations
Unique Elements
Blow Your Stack
Comparing Arrays
Changing Elements
Deleting Elements
Arrays and Blocks
Sorting Things and About Face
Multidimensional Arrays
1.9 and Beyond
Other Array Methods
Review Questions
7. Hashes
Creating Hashes
Accessing Hashes
Iterating over Hashes
Changing Hashes
Converting Hashes to Other Classes
1.9 and Beyond
Other Hash Methods
Review Questions
8. Working with Files
Directories
Creating a New File
Opening an Existing File
Deleting and Renaming Files
File Inquiries
Changing File Modes and Owner
The IO Class
Review Questions
9. Classes
Defining the Class
Instance Variables
Accessors
Class Variables
Class Methods
Inheritance
Modules
public, private, or protected
Review Questions
10. More Fun with Ruby
Formatting Output with sprintf
Processing XML
Date and Time
Reflection
Using Tk
Metaprogramming
RubyGems
Exception Handling
Creating Documentation with RDoc
Embedded Ruby
Review Questions
11. A Short Guide to Ruby on Rails
Where Did Rails Come From?
Why Rails?
What Have Other Folks Done with Rails?
Hosting Rails
Installing Rails
Learning Rails
A Brief Tutorial
Review Questions
A. Ruby Reference
B. Answers to Review Questions
Glossary
Index