Learning Ruby

Free Download

Authors:

Edition: 1st ed

ISBN: 9780596529864, 0596529864

Size: 2 MB (2523211 bytes)

Pages: 257/257

File format:

Language:

Publishing Year:

Category:

Michael James Fitzgerald9780596529864, 0596529864

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.

Table of contents :
Learning Ruby……Page 1
Table of Contents……Page 8
How This Book Works……Page 12
How This Book Is Organized……Page 13
Comments and Questions……Page 15
Acknowledgments……Page 16
Ruby Basics……Page 18
A Very Short Ruby Program……Page 19
Shebang!……Page 20
Appending a String……Page 21
Using a Variable……Page 22
Formatting a String……Page 23
Getting Input from the Keyboard……Page 24
The each Method……Page 25
The Class……Page 26
The Tk Toolkit……Page 27
Editing and Running Ruby in TextMate……Page 28
Interactive Ruby……Page 29
Resources……Page 30
Installing Ruby on Mac OS X Tiger……Page 32
Installing Ruby on Windows with the One-Click Installer……Page 34
Installing Ruby on Windows with Binaries……Page 36
Permission Denied……Page 37
Associating File Types on Windows……Page 38
Review Questions……Page 39
Ruby Is Object-Oriented……Page 40
The Object Class and the Kernel Module……Page 42
Ruby’s Reserved Words……Page 43
Comments……Page 44
Variables……Page 45
Global Variables……Page 46
Strings……Page 47
Regular Expressions……Page 49
Numbers and Operators……Page 50
Arrays and Hashes……Page 51
Methods……Page 52
Return Values……Page 53
Method Name Conventions……Page 54
Variable Arguments……Page 55
Aliasing Methods……Page 56
The yield Statement……Page 57
Procs……Page 59
Symbols……Page 60
Exception Handling……Page 61
Review Questions……Page 62
The if Statement……Page 64
Using else and elsif……Page 66
The case Statement……Page 68
The while Loop……Page 69
unless and until……Page 71
The loop Method……Page 72
The for loop……Page 73
The upto Method……Page 74
The downto Method……Page 75
Review Questions……Page 76
Creating Strings……Page 77
General Delimited Strings……Page 78
Here Documents……Page 79
Accessing Strings……Page 80
Comparing Strings……Page 82
Changing All or Part of a String……Page 83
The chomp and chop Methods……Page 84
Substitute the Substring……Page 85
From a String to an Array……Page 86
Iterating Over a String……Page 87
Managing Whitespace, etc…….Page 88
Incrementing Strings……Page 90
Regular Expressions……Page 91
Review Questions……Page 95
Math……Page 96
Class Hierarchy and Included Modules……Page 97
Basic Math Operations……Page 98
Division and Truncation……Page 99
Abbreviated Assignment Operators……Page 100
Ranges……Page 102
Inquiring About Numbers……Page 103
Iterating Through Blocks……Page 104
Math Functions……Page 105
Rational Numbers……Page 107
Just for Fun……Page 108
Review Questions……Page 109
Arrays……Page 110
Creating Arrays……Page 111
There’s an Easier Way……Page 112
It Gets Even Easier……Page 113
Accessing Elements……Page 114
Set Operations……Page 116
Blow Your Stack……Page 117
Changing Elements……Page 118
As a String……Page 119
Arrays and Blocks……Page 120
Multidimensional Arrays……Page 121
Review Questions……Page 122
Creating Hashes……Page 124
Accessing Hashes……Page 125
Iterating over Hashes……Page 126
Merging Hashes……Page 127
Deleting and Clearing a Hash……Page 128
Replacing a Hash……Page 129
1.9 and Beyond……Page 130
Review Questions……Page 131
Directories……Page 132
The Directory Stream……Page 133
Opening an Existing File……Page 134
ARGV and ARGF……Page 135
Opening a URI……Page 136
File Inquiries……Page 137
Changing File Modes and Owner……Page 138
The IO Class……Page 140
Review Questions……Page 141
Classes……Page 142
Defining the Class……Page 143
Instance Variables……Page 144
Accessors……Page 146
Class Variables……Page 147
Class Methods……Page 148
Singletons……Page 149
Inheritance……Page 150
Modules……Page 151
public, private, or protected……Page 154
Review Questions……Page 155
Formatting Output with sprintf……Page 156
Processing XML……Page 159
REXML……Page 160
Builder……Page 162
The Time Class……Page 164
The Date Class……Page 166
Calendar forms……Page 167
Reflection……Page 168
Reflection on Variables and Constants……Page 170
Using Tk……Page 171
Metaprogramming……Page 174
RubyGems……Page 175
Exception Handling……Page 179
RDoc Basics……Page 181
Processing Files with RDoc……Page 186
Embedded Ruby……Page 188
Review Questions……Page 191
Where Did Rails Come From?……Page 192
Why Rails?……Page 193
I Want My MVC……Page 194
Ajax……Page 195
Environments and Testing……Page 196
What Have Other Folks Done with Rails?……Page 197
Installing Rails……Page 199
Using RubyGems to install Rails……Page 200
Learning Rails……Page 202
A Brief Tutorial……Page 203
Review Questions……Page 210
Ruby Interpreter……Page 212
Ruby’s Reserved Words……Page 213
Escape Characters……Page 215
Predefined Variables……Page 216
Global Constants……Page 218
Regular Expressions……Page 219
String Unpack Directives……Page 220
Array Pack Directives……Page 222
Sprintf Flags and Field Types……Page 223
File Tests……Page 224
Time Formatting Directives……Page 225
RDoc Options……Page 226
Rake……Page 229
Chapter2 Review Questions……Page 231
Chapter4 Review Questions……Page 232
Chapter7 Review Questions……Page 233
Chapter10 Review Questions……Page 234
Chapter11 Review Questions……Page 235
Glossary……Page 236
Index……Page 244

Reviews

There are no reviews yet.

Be the first to review “Learning Ruby”
Shopping Cart
Scroll to Top