TIENE EN SU CESTA DE LA COMPRA
en total 0,00 €
For more than a decade, Ruby developers have turned to The Ruby Way for reliable "how-toö guidance on effective Ruby programming. Now, Hal Fulton and André Arko have thoroughly updated this classic guide to cover new language enhancements and developers' experiences through Ruby 2.1.
The new edition illuminates Ruby 2.1 through 400+ examples, each answering the question: "How do I do this in Ruby?ö For each example, they present both a task description and realistic technical constraints. Next, they walk step-by-step through presenting one good solution, offering detailed explanations to promote deeper understanding.
Conveniently organized by topic, The Ruby Way, Third Edition makes it easier than ever to find the specific solution you want-and to write better code by reflecting Ruby's unique philosophy and spirit.
Coverage includes
Ruby 2.1 overview: terminology, philosophy, and basic principles
Best practices for strings and regular expressions
Efficiently internationalizing your code
Performing calculations (including trigonometry, calculus, statistics, and time/date calculations)
Working with "Rubyesqueö objects such as symbols and ranges
Using arrays, hashes, stacks, queues, trees, graphs, and other data structures
Efficiently storing data with YAML, JSON, and SQLite3
Leveraging object-oriented and dynamic features, from multiple constructors to program inspection
Building GUIs with Shoes 4, Ruby/Tk, Ruby/GTK3, QtRuby, and other toolkits
Improving thread performance by understanding Ruby's synchronization methods and avoiding its pitfalls
Automating system administration with Ruby
Data formats: JSON, XML, RSS, Atom, RMagick, PDF, and more
Testing and debugging with RSpec, Minitest, Cucumber, byebug, and pry
Measuring Ruby program performance
Packaging and distributing code, and managing dependencies with Bundler
Network programming: clients, time servers, POP, SMTP, IMAP, Open-URI
Web applications: HTTP servers, Rails, Sinatra, HTML generation, and more
Writing distributed Ruby software with drb
Choosing modern development tools that maximize your productivity
Foreword xxiv
Acknowledgments xxviii
About the Authors xxxii
Introduction xxxiii
1 Ruby in Review 1
1.1 An Introduction to Object Orientation 2
1.1.1 What Is an Object? 2
1.1.2 Inheritance 4
1.1.3 Polymorphism 6
1.1.4 A Few More Terms 7
1.2 Basic Ruby Syntax and Semantics 8
1.2.1 Keywords and Identifiers 9
1.2.2 Comments and Embedded Documentation 10
1.2.3 Constants, Variables, and Types 11
1.2.4 Operators and Precedence 13
1.2.5 A Sample Program 14
1.2.6 Looping and Branching 17
1.2.7 Exceptions 22
1.3 OOP in Ruby 25
1.3.1 Objects 26
1.3.2 Built-in Classes 26
1.3.3 Modules and Mixins 28
1.3.4 Creating Classes 29
1.3.5 Methods and Attributes 34
1.4 Dynamic Aspects of Ruby 36
1.4.1 Coding at Runtime 36
1.4.2 Reflection 38
1.4.3 Missing Methods 40
1.4.4 Garbage Collection 40
1.5 Training Your Intuition: Things to Remember 41
1.5.1 Syntax Issues 41
1.5.2 Perspectives in Programming 44
1.5.3 Ruby's case Statement 47
1.5.4 Rubyisms and Idioms 50
1.5.5 Expression Orientation and Other Miscellaneous Issues 57
1.6 Ruby Jargon and Slang 59
1.7 Conclusion 62
2 Working with Strings 63
2.1 Representing Ordinary Strings 64
2.2 Representing Strings with Alternate Notations 65
2.3 Using Here-Documents 65
2.4 Finding the Length of a String 67
2.5 Processing a Line at a Time 68
2.6 Processing a Character or Byte at a Time 68
2.7 Performing Specialized String Comparisons 69
2.8 Tokenizing a String 71
2.9 Formatting a String 73
2.10 Using Strings as IO Objects 74
2.11 Controlling Uppercase and Lowercase 74
2.12 Accessing and Assigning Substrings 75
2.13 Substituting in Strings 78
2.14 Searching a String 79
2.15 Converting Between Characters and ASCII Codes 80
2.16 Implicit and Explicit Conversion 80
2.17 Appending an Item onto a String 83
2.18 Removing Trailing Newlines and Other Characters 83
2.19 Trimming Whitespace from a String 84
2.20 Repeating Strings 85
2.21 Embedding Expressions within Strings 85
2.22 Delayed Interpolation of Strings 86
2.23 Parsing Comma-Separated Data 86
2.24 Converting Strings to Numbers (Decimal and Otherwise) 87
2.25 Encoding and Decoding rot13 Text 89
2.26 Encrypting Strings 90
2.27 Compressing Strings 91
2.28 Counting Characters in Strings 92
2.29 Reversing a String 92
2.30 Removing Duplicate Characters 93
2.31 Removing Specific Characters 93
2.32 Printing Special Characters 93
2.33 Generating Successive Strings 94
2.34 Calculating a 32-Bit CRC 94
2.35 Calculating the SHA-256 Hash of a String 95
2.36 Calculating the Levenshtein Distance Between Two Strings 96
2.37 Encoding and Decoding Base64 Strings 98
2.38 Expanding and Compressing Tab Characters 98
2.39 Wrapping Lines of Text 99
2.40 Conclusion 100
3 Working with Regular Expressions 101
3.1 Regular Expression Syntax 102
3.2 Compiling Regular Expressions 104
3.3 Escaping Special Characters 105
3.4 Using Anchors 105
3.5 Using Quantifiers 106
3.6 Positive and Negative Lookahead 109
3.7 Positive and Negative Lookbehind 110
3.8 Accessing Backreferences 111
3.9 Named Matches 114
3.10 Using Character Classes 116
3.11 Extended Regular Expressions 118
3.12 Matching a Newline with a Dot 119
3.13 Using Embedded Options 119
3.14 Using Embedded Subexpressions 120
3.14.1 Recursion in Regular Expressions 121
3.15 A Few Sample Regular Expressions 122
3.15.1 Matching an IP Address 122
3.15.2 Matching a Keyword-Value Pair 123
3.15.3 Matching Roman Numerals 124
3.15.4 Matching Numeric Constants 125
3.15.5 Matching a Date/Time String 125
3.15.6 Detecting Doubled Words in Text 126
3.15.7 Matching All-Caps Words 127
3.15.8 Matching Version Numbers 127
3.15.9 A Few Other Patterns 127
3.16 Conclusion 128
4 Internationalization in Ruby 129
4.1 Background and Terminology 131
4.2 Working with Character Encodings 135
4.2.1 Normalization 136
4.2.2 Encoding Conversions 139
4.2.3 Transliteration 141
4.2.4 Collation 141
4.3 Translations 144
4.3.1 Defaults 146
4.3.2 Namespaces 147
4.3.3 Interpolation 148
4.3.4 Pluralization 149
4.4 Localized Formatting 151
4.4.1 Dates and Times 151
4.4.2 Numbers 152
4.4.3 Currencies 153
4.5 Conclusion 153
5 Performing Numerical Calculations 155
5.1 Representing Numbers in Ruby 156
5.2 Basic Operations on Numbers 157
5.3 Rounding Floating Point Values 158
5.4 Comparing Floating Point Numbers 160
5.5 Formatting Numbers for Output 162
5.6 Formatting Numbers with Commas 162
5.7 Working with Very Large Integers 163
5.8 Using BigDecimal 163
5.9 Working with Rational Values 166
5.10 M