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 . . .
Writing real code quickly using interactive Ruby (irb)
Working with native Ruby objects and creating your own
Using functional techniques to write more concise and modular code
Creating tests and improving code with test-driven development (TDD)
Developing and publishing self-contained Ruby packages (gems)
Writing nontrivial shell scripts to leverage Ruby's power at the command line
Developing and deploying a web app with routes, layouts, embedded Ruby, and forms
Mastering modern development skills you can use with any language
Michael Hartl's Learn Enough Series includes books and video courses that focus on the most important parts of each subject, so you don't have to learn everything to get started--you just have to learn enough to be dangerous and solve technical problems yourself.
Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.
Rezensionen / Stimmen
Praise for Learn Enough Tutorials
"Just started the #100DaysOfCode journey. Today marks day 1. I have completed @mhartl's great Ruby tutorial at @LearnEnough and am looking forward to starting on Ruby on Rails from tomorrow. Onwards and upwards."
--Optimize Prime (@_optimize), Twitter post
"Ruby and Sinatra and Heroku, oh my! Almost done with this live web application. It may be a simple palindrome app, but it's also simply exciting! #100DaysOfCode #ruby @LearnEnough #ABC #AlwaysBeCoding #sinatra #heroku"
--Tonia Del Priore (@toninjaa), Twitter post; Software Engineer for a FinTech Startup for 3+ years
"I must say, this Learn Enough series is a masterpiece of education. Thank you for this incredible work!"
--Michael King
"I want to thank you for the amazing job you have done with the tutorials. They are likely the best tutorials I have ever read."
--Pedro Iatzky
Auflage
Sprache
Verlagsort
Verlagsgruppe
Zielgruppe
Dateigröße
ISBN-13
978-0-13-784418-0 (9780137844180)
Copyright in bibliographic data and cover images is held by Nielsen Book Services Limited or by the publishers or by their respective licensors: all rights reserved.
Schweitzer Klassifikation
Michael Hartl created the legendary Ruby on Rails (TM) Tutorial that helped jumpstart thousands of web development careers. A cofounder and principal author at Learn Enough, Hartl previously earned a Ph.D. in physics at the California Institute of Technology (Caltech), where he received a Lifetime Achievement Award for Excellence in Teaching. He is also an alumnus of Harvard University and the world-renowned Y Combinator entrepreneur program.
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