Just started the #100DaysOfCode journey. Today marks day 1. I have completed @mhartls great Ruby tutorial at @LearnEnough and am looking forward to starting on Ruby on Rails from tomorrow. Onwards and upwards.
Ruby and Sinatra and Heroku, oh my! Almost done with this live web application. It may be a simple palindrome app, but its also simply exciting! #100DaysOfCode #ruby @LearnEnough #ABC #AlwaysBeCoding #sinatra #heroku
I must say, this Learn Enough series is a masterpiece of education. Thank you for this incredible work!
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.
Learn Enough Ruby to Be Dangerous
Write Programs, Publish Gems, and Develop Sinatra Web Apps with Ruby
Michael Hartl
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Cover image: Philipp Tur/Shutterstock
: Sinatra
, Inc.
: Apple Inc.
: GitHub, Inc.
: Salesforce, Inc.
: Ruby-doc.org
: Courtesy of Mike Vanier
: Michael Lovitt
: Google
: Courtesy of David Heinemeier Hansson
: Wikimedia Foundation, Inc
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 publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/aw
Copyright 2022 Softcover Inc.
All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearson.com/permissions.
eBook ISBN-13: 978-0-13-784418-0
eBook ISBN-10: 0-13-784418-2
ePub ISBN-13: 978-0-13-784411-1
ePub ISBN-10: 0-13-784411-5
Release 1, June 2022
Preface
Learn Enough Ruby to Be Dangerous teaches you to write practical and modern programs using the elegant and powerful Ruby programming language. Youll learn how to use Ruby for both general-purpose programming and for beginning web-application development. Although mastering Ruby can be a long journey, you dont have to learn everything to get started you just have to learn enough to be dangerous.
Youll begin by exploring the core concepts of Ruby programming using a combination of interactive Ruby and text files run at the command line. The result is a solid understanding of both object-oriented programming and functional programming in Ruby. Youll then build on this foundation to develop and publish a simple self-contained Ruby package, or Ruby gem. Youll then use this gem in a simple dynamic web application built using the Sinatra web framework, which youll also deploy to the live Web. As a result, Learn Enough Ruby to Be Dangerous is especially appropriate as a prerequisite to the Ruby on Rails Tutorial, a bestselling web-development tutorial by the same author.
In addition to teaching you specific skills, Learn Enough Ruby to Be Dangerous also helps you develop technical sophisticationthe seemingly magical ability to solve practically any technical problem. Technical sophistication includes concrete skills like version control and coding, as well as fuzzier skills like Googling the error message and knowing when to just reboot the darn thing. Throughout Learn Enough Ruby to Be Dangerous, well have abundant opportunities to develop technical sophistication in the context of real-world examples.
Chapter by Chapter
In order to learn enough Ruby to be dangerous, well begin at the beginning with a series of simple well deploy a (very simple) dynamic Ruby application to the live Web.
After mastering hello, world, well take a tour of some Ruby objects, including strings (). Taken together, these chapters constitute a gentle introduction to object-oriented programming with Ruby.
In ).
Having covered the basics of built-in Ruby objects, in well learn how to make objects of our own. In particular, well define an object for a phrase, and then develop a method for determining whether or not the phrase is a palindrome (the same read forward and backward).
Our initial palindrome implementation will be rather rudimentary, but well extend it in using a powerful technique called