HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
All You Need to Know, and Nothing You Don't, to Create Ruby Programs, Gems, and Web Apps
Programmers love Ruby for its elegance, power, and flexibility: that's why it was chosen for the Ruby on Rails framework that launched websites from Shopify to Coinbase. You'll love Ruby too, but you don't need to learn "everything" about it, just how to use it efficiently to solve real problems. In Learn Enough Ruby to Be Dangerous, renowned instructor Michael Hartl teaches the concepts, skills, and approaches you need to be professionally productive in both general-purpose programming and beginning web app development.
Even if you're new to programming, Hartl helps you quickly build technical sophistication and master the lore you need to succeed. You'll gain a solid understanding of object-oriented and functional programming, develop and publish a self-contained Ruby package (a gem), and use your gem to build and deploy a dynamic web app with the Sinatra framework. Focused exercises help you internalize what matters, without wasting time on details pros don't care about. Soon, it'll be like you were born knowing this stuff--and you'll be suddenly, seriously dangerous.
Learn enough about . . .
Please download the companion code files at https://github.com/learnenough/learn_enough_ruby_code_listings.
Preface v
About the Author ix
Chapter 1: Hello, World! 1
1.1 Introduction to Ruby 7
1.2 Ruby in a REPL 10
1.3 Ruby in a File 12
1.4 Ruby in a Shell Script 13
1.5 Ruby in a Web Browser 16
Chapter 2: Strings 31
2.1 String Basics 31
2.2 Concatenation and Interpolation 32
2.3 Printing 40
2.4 Attributes, Booleans, and Control Flow 42
2.5 Methods 53
2.6 String Iteration 59
Chapter 3: Arrays 67
3.1 Splitting 67
3.2 Array Access 69
3.3 Array Slicing 71
3.4 More Array Methods 73
3.5 Array Iteration 76
Chapter 4: Other Native Objects 81
4.1 Math 81
4.2 Time 86
4.3 Regular Expressions 92
4.4 Hashes 100
4.5 Application: Unique Words 105
Chapter 5: Functions and Blocks 111
5.1 Function Definitions 111
5.2 Functions in a File 114
5.3 Method Chaining 123
5.4 Blocks 128
Chapter 6: Functional Programming 135
6.1 Map 137
6.2 Select 145
6.3 Reduce 149
Chapter 7: Objects and Classes 161
7.1 Defining Classes 161
7.2 Inheritance 170
7.3 Derived Classes 176
7.4 Modifying Native Objects 184
7.5 Modules 192
Chapter 8: Testing and Test-Driven Development 197
8.1 Testing and Ruby Gem Setup 199
8.2 Initial Test Coverage 203
8.3 Red 214
8.4 Green 221
8.5 Refactor 226
Chapter 9: Shell Scripts 239
9.1 Reading from Files 240
9.2 Reading from URLs 246
9.3 DOM Manipulation at the Command Line 250
Chapter 10: A Live Web Application 261
10.1 Setup 262
10.2 Site Pages 266
10.3 Layouts 277
10.4 Embedded Ruby 291
10.5 Palindrome Detector 304
10.6 Conclusion 328