Programming.Ruby.1.9.The.Pragmatic.Programmers.Guide.3rd.Edition.Apr.2009.ISBN.1934356085.pdf
(
4403 KB
)
Pobierz
Programming Ruby 1.9
The Pragmatic Programmers’ Guide
Dave Thomas
with
Chad Fowler
Andy Hunt
The Pragmatic Bookshelf
Raleigh, North Carolina
Dallas, Texas
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.
Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim,
the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic
Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking
g
device are trademarks of The Pragmatic
Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors
or omissions, or for damages that may result from the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more
fun. For more information, as well as the latest Pragmatic titles, please visit us at
http://www.pragprog.com
.
Copyright
©
2010 The Pragmatic Programmers, LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means,
electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN-10: 1-934356-08-5
ISBN-13: 978-1-934356-08-1
Printed on acid-free paper.
3.0 printing, November 2010
Version: 2010-11-15
Contents
Foreword
11
Preface
12
Why Ruby?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12
Ruby Versions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
Changes in the Book
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
Resources
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14
Acknowledgments
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14
Notation Conventions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
16
Road Map
17
I
Facets of Ruby
19
1
Getting Started
20
1.1
The Command Prompt
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
20
1.2
Installing Ruby
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
22
1.3
Running Ruby
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
1.4
Ruby Documentation: RDoc and ri
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
29
2
Ruby.new
32
2.1
Ruby Is an Object-Oriented Language
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
32
2.2
Some Basic Ruby
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
34
2.3
Arrays and Hashes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
2.4
Symbols
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
39
2.5
Control Structures
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
40
2.6
Regular Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
41
2.7
Blocks and Iterators
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
43
2.8
Reading and ’Riting
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
45
2.9
Command-Line Arguments
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
46
2.10
Onward and Upward
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
46
CONTENTS
5
3
Classes, Objects, and Variables
47
3.1
Objects and Attributes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
50
3.2
Classes Working with Other Classes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
55
3.3
Access Control
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
58
3.4
Variables
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
61
4
Containers, Blocks, and Iterators
63
4.1
Arrays
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
63
4.2
Hashes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
66
4.3
Blocks and Iterators
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
70
4.4
Containers Everywhere
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
85
5
Sharing Functionality: Inheritance, Modules, and Mixins
86
5.1
Inheritance and Messages
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
86
5.2
Modules
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
91
5.3
Mixins
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
93
5.4
Iterators and the Enumerable Module
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
95
5.5
Composing Modules
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
95
5.6
Inheritance, Mixins, and Design
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
98
6
Standard Types
100
6.1
Numbers
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
100
6.2
Strings
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
103
6.3
Ranges
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
107
7
Regular Expressions
111
7.1
What Regular Expressions Let You Do
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
111
7.2
Ruby’s Regular Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
112
7.3
Digging Deeper
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
114
7.4
Advanced Regular Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
123
8
More About Methods
131
8.1
Defining a Method
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
131
8.2
Calling a Method
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
134
9
Expressions
139
9.1
Operator Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
139
9.2
Miscellaneous Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
141
9.3
Assignment
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
142
9.4
Conditional Execution
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
146
9.5
case Expressions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
150
9.6
Loops
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
152
9.7
Variable Scope, Loops, and Blocks
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
156
Report erratum
this copy is (3.0 printing, November 2010)
Plik z chomika:
drumate
Inne pliki z tego folderu:
Pragmatic.Bookshelf.Build.Awesome.Command.Line.Applications.In.Ruby.2.Nov.2013.ISBN.1937785750.pdf
(4958 KB)
Programming.Ruby.1.9.The.Pragmatic.Programmers.Guide.3rd.Edition.Apr.2009.ISBN.1934356085.pdf
(4403 KB)
Practical OO Design Ruby 0321721330.pdf
(1342 KB)
The Rails 4 Way, 3rd Edition.pdf
(3831 KB)
Eloquent Ruby.pdf
(4515 KB)
Inne foldery tego chomika:
Algorithm
database
Graph
Hardware
IT private, pass is cmn
Zgłoś jeśli
naruszono regulamin