INDEX >
Introduction
Book Cover
Foreword
Preface
Ruby Sparkles
What Kind of Language Is Ruby?
Is Ruby for Me?
Why Did We Write This Book?
Ruby Versions
Installing Ruby
Building Ruby
Running Ruby
Interactive Ruby
Ruby Programs
Resources
Acknowledgments
Notation Conventions
Roadmap
Facets of Ruby
Ruby.new
Ruby Is an Object-Oriented Language
Some Basic Ruby
Arrays and Hashes
Control Structures
Regular Expressions
Blocks and Iterators
Reading and 'Riting
Onward and Upward
Classes, Objects, and Variables
Inheritance and Messages
Inheritance and Mixins
Objects and Attributes
Writable Attributes
Virtual Attributes
Class Variables and Class Methods
Class Variables
Class Methods
Singletons and Other Constructors
Access Control
Specifying Access Control
Variables
Containers, Blocks, and Iterators
Containers
Arrays
Hashes
Implementing a SongList Container
Blocks and Iterators
Implementing Iterators
Ruby Compared with C++ and Java
Blocks for Transactions
Blocks Can Be Closures
Standard Types
Numbers
Strings
Working with Strings
Ranges
Ranges as Sequences
Ranges as Conditions
Ranges as Intervals
Regular Expressions
Patterns
Anchors
Character Classes
Repetition
Alternation
Grouping
Pattern-Based Substitution
Backslash Sequences in the Substitution
Object-Oriented Regular Expressions
More About Methods
Defining a Method
Variable-Length Argument Lists
Methods and Blocks
Calling a Method
Expanding Arrays in Method Calls
Making Blocks More Dynamic
Collecting Hash Arguments
Expressions
Operator Expressions
Miscellaneous Expressions
Command Expansion
Backquotes Are Soft
Assignment
Parallel Assignment
Nested Assignments
Other Forms of Assignment
Conditional Execution
Boolean Expressions
Defined?, And, Or, and Not
If and Unless Expressions
If and Unless Modifiers
Case Expressions
Loops
Iterators
For ... In
Break, Redo, and Next
Retry
Variable Scope and Loops
Exceptions, Catch, and Throw
The Exception Class
Handling Exceptions
Tidying Up
Play It Again
Raising Exceptions
Adding Information to Exceptions
Catch and Throw
Modules
Namespaces
Mixins
Instance Variables in Mixins
Iterators and the Enumerable Module
Including Other Files
Basic Input and Output
What Is an IO Object?
Opening and Closing Files
Reading and Writing Files
Iterators for Reading
Writing to Files
But I Miss My C++ Iostream
Talking to Networks
Threads and Processes
Multithreading
Creating Ruby Threads
Manipulating Threads
Thread Variables
Threads and Exceptions
Controlling the Thread Scheduler
Mutual Exclusion
The Mutex Class
Condition Variables
Running Multiple Processes
Spawning New Processes
Independent Children
Blocks and Subprocesses
When Trouble Strikes
Ruby Debugger
Interactive Ruby
Editor Support
But It Doesn't Work!
But It's Too Slow!
Create Locals Outside Blocks
Use the Profiler
Ruby in Its Setting
Ruby and Its World
Command-Line Arguments
Command-Line Options
ARGV
Program Termination
Environment Variables
Writing to Environment Variables
Where Ruby Finds Its Modules
Build Environment
Ruby and the Web
Writing CGI Scripts
Using cgi.rb
Quoting
Forms
Creating Forms and HTML
Cookies
Sessions
Embedding Ruby in HTML
Using eruby
Installing eruby in Apache
Improving Performance
Ruby Tk
Simple Tk Application
Widgets
Setting Widget Options
Getting Widget Data
Setting/Getting Options Dynamically
Sample Application
Binding Events
Canvas
Scrolling
Just One More Thing
Translating from Perl/Tk Documentation
Object Creation
Options
Variable References
Ruby and Microsoft Windows
Ruby Ports
Running Ruby Under Windows
Win32API
Windows Automation
Getting and Setting Properties
Named Arguments
for each
An Example
Optimizing
Extending Ruby
Ruby Objects in C
VALUE as a Pointer
VALUE as an Immediate Object
Writing Ruby in C
Evaluating Ruby Expressions in C
Sharing Data Between Ruby and C
Directly Sharing Variables
Wrapping C Structures
C Datatype Wrapping
An Example
Memory Allocation
Creating an Extension
Creating a Makefile with extconf.rb
Static Linking
Embedding a Ruby Interpreter
Embedded Ruby API
Bridging Ruby to Other Languages
Ruby C Language API
Defining Objects
Defining Methods
Defining Variables and Constants
Calling Methods
Exceptions
Iterators
Accessing Variables
Object Status
Commonly Used Methods
Ruby Crystallized
The Ruby Language
Source Layout
BEGIN and END Blocks
General Delimited Input
The Basic Types
Integer and Floating Point Numbers
Strings
Ranges
Arrays
Hashes
Requirements for a Hash Key
Symbols
Regular Expressions
Regular Expression Options
Regular Expression Patterns
Substitutions
Extensions
Names
Variable/Method Ambiguity
Variables and Constants
Scope of Constants and Variables
Predefined Variables
Exception Information
Pattern Matching Variables
Input/Output Variables
Execution Environment Variables
Standard Objects
Global Constants
Expressions
Single Terms
Operator Expressions
More on Assignment
Parallel Assignment
Block Expressions
Boolean Expressions
Truth Values
And, Or, Not, and Defined?
Comparison Operators
Ranges in Boolean Expressions
Regular Expressions in Boolean Expressions
If and Unless Expressions
If and Unless Modifiers
Ternary Operator
Case Expressions
Loops
While and Until Modifiers
Break, Redo, Next, and Retry
Method Definition
Method Arguments
Invoking a Method
super
Operator Methods
Attribute Assignment
Element Reference Operator
Aliasing
Class Definition
Creating Objects from Classes
Class Attribute Declarations
Module Definitions
Mixins—Including Modules
Module Functions
Access Control
Blocks, Closures, and Proc Objects
Proc Objects
Exceptions
Raising Exceptions
Handling Exceptions
Retrying a Block
Catch and Throw
Classes and Objects
How Classes and Objects Interact
Your Basic, Everyday Object
What's the Meta?
Object-Specific Classes
Mixin Modules
Extending Objects
Class and Module Definitions
Class Names Are Constants
Top-Level Execution Environment
Inheritance and Visibility
Freezing Objects
Locking Ruby in the Safe
Safe Levels
Tainted Objects
Reflection, ObjectSpace, and Distributed Ruby
Looking at Objects
Looking Inside Objects
Looking at Classes
Looking Inside Classes
Calling Methods Dynamically
Performance Considerations
System Hooks
Runtime Callbacks
Tracing Your Program's Execution
How Did We Get Here?
Marshaling and Distributed Ruby
Custom Serialization Strategy
Distributed Ruby
Compile Time? Runtime? Anytime!
Ruby Library Reference
Built-in Classes and Methods
Classes
Array
Bignum
Binding
Class
Continuation
Dir
Exception
FalseClass
File::Stat
File
Fixnum
Float
Hash
Integer
IO
MatchData
Method
Module
NilClass
Numeric
Object
Proc
Range
Regexp
String
Struct
Struct::Tms
Symbol
ThreadGroup
Thread
Time
TrueClass
Modules
Comparable
Enumerable
Errno
FileTest
GC
Kernel
Marshal
Math
ObjectSpace
Process
Standard Library
Complex class
constants
class methods
new
instance methods
Arithmetic operations
<=>
==
abs
abs2
arg
conjugate
image
polar
real
to_f
to_i
to_r
to_s
Date class
mixins
class methods
exist2?
exist?
existw?
gregorian_leap?
julian_leap?
leap?
new
new1
new2
new3
neww
today
instance methods
Accessors
+
-
<<
<=>
===
>>
downto
england
gregorian
italy
jd
julian
leap?
mjd
newsg
next
ns?
os?
sg
step
succ
to_s
upto
English library
Find module
class methods
find
prune
File class
class methods
cmp
compare
copy
cp
install
makedirs
mkpath
move
mv
rm_f
safe_unlink
syscopy
GetoptLong class
constants
class methods
new
instance methods
each
error?
error_message
get
get_option
ordering
ordering=
quiet
quiet=
quiet?
set_options
terminate
terminated?
mkmf module
constants
instance methods
create_makefile
dir_config
find_library
have_func
have_header
have_library
ParseDate module
class methods
parsedate
profile library
PStore class
class methods
new
instance methods
[ ]
[ ]=
abort
commit
path
root?
roots
transaction
Tempfile class
class methods
new
open
instance methods
close
open
path
Mutex class
instance methods
lock
locked?
synchronize
try_lock
unlock
ConditionVariable class
instance methods
broadcast
signal
wait
timeout library
WeakRef class
class methods
new
instance methods
weakref_alive?
Object-Oriented Design Libraries
The Visitor Pattern
delegate library
observer library
singleton library
Network and Web Libraries
Socket-Level Access
BasicSocket class
class methods
do_not_reverse_lookup
do_not_reverse_lookup=
lookup_order
lookup_order=
instance methods
close_read
close_write
getpeername
getsockname
getsockopt
recv
send
setsockopt
shutdown
IPSocket class
class methods
getaddress
instance methods
addr
peeraddr
TCPSocket class
class methods
gethostbyname
new
open
instance methods
recvfrom
SOCKSSocket class
class methods
new
open
instance methods
close
TCPServer class
class methods
new
open
instance methods
accept
UDPSocket class
class methods
new
open
instance methods
bind
connect
recvfrom
send
UNIXSocket class
class methods
new
open
instance methods
addr
path
peeraddr
recvfrom
UNIXServer class
class methods
new
open
instance methods
accept
Socket class
constants
class methods
for_fd
getaddrinfo
gethostbyaddr
gethostbyname
gethostname
getnameinfo
getservbyname
new
open
pair
socketpair
instance methods
accept
bind
connect
listen
recvfrom
Higher-Level Access
Net::FTP class
constants
class methods
new
open
instance methods
Server commands
close
closed?
connect
debug_mode
debug_mode=
dir
getbinaryfile
gettextfile
lastresp
list
login
ls
mtime
passive
passive=
putbinaryfile
puttextfile
resume
resume=
retrbinary
retrlines
return_code
storbinary
storlines
welcome
Net::HTTP class
class methods
new
port
start
instance methods
get
head
post
start
Net::HTTPResponse class
instance methods
[ ]
[ ]=
code
each
key?
message
Net::POP class
class methods
new
instance methods
each
finish
mails
start
Net::APOP class
instance methods
start
Net::POPMail class
instance methods
all
delete
delete!
header
size
top
uidl
Net::SMTP class
class methods
new
start
instance methods
ready
sendmail
start
Net::Telnet class
class methods
new
instance methods
binmode
binmode=
cmd
login
print
telnetmode
telnetmode=
waitfor
write
CGI Development
CGI class
class methods
escape
escapeElement
escapeHTML
new
parse
pretty
rfc1123_date
unescape
unescapeElement
unescapeHTML
instance methods
[ ]
cookies
has_key?
header
keys
out
params
HTML Output Methods
Multipart Form Values
CGI::Session class
class methods
new
instance methods
[ ]
[ ]=
delete
update
Microsoft Windows Support
WIN32OLE class
constants
class methods
connect
const_load
new
instance methods
[ ]
[ ]=
each
invoke
WIN32OLE_EVENT class
class methods
message_loop
new
instance methods
on_event
Win32API class
class methods
new
instance methods
call
Call
Appendices
Embedded Documentation
Inline Formatting
Cross References
Method Names
Including Other Files
Using rdtool
Mandatory Disclaimer
Interactive Ruby Shell
Command Line
Initialization File
Commands
Configuring the Prompt
Restrictions
rtags, xmp, and the Frame Class
rtags
xmp
The Frame Class
Support
Web Sites
Download Sites
Usenet Newsgroup
Mailing Lists
Bug Reporting
Download this Site
(2006-Oct-16)