Learn Ruby today!
Ruby is famous for being easy to learn but most users only scratch the surface of what it can do. While a typical Ruby tutorial or book focuses on Ruby's trendier features this course reveals the secret inner workings of one of the world's most popular programming
languages. It helps you learn Ruby in one of the easiest ways possible through 10 simple steps that will have you writing clear maintainable code in no time. Rather than bog you down with a lot of theory this course takes a hands-on approach and focuses on helping you learn Ruby so that you'reproductive on day one.
Whether you're new to programming or just new to Ruby this Ruby tutorial is your guide to rapid real-world software development withthis unique and elegant language.
Who uses Ruby?
Ruby is an incredibly powerful and highly scalable object-oriented language. Leading technology companies & startups around the world use Ruby or the Ruby on Rails framework to power their websites & web applications. They include:
* Electronic Arts
* New York Times
* 37 Signals
* And many many more...
Welcome to the course! This is a short introduction to the Ruby language and a few words about what you can expect from this course.
The Little Book Of Ruby (4th edition) is the 'course text'. It covers all the topics in this course in ten chapters. Click the download tab on the right to download a copy for offline reference. Be sure to download the code archive too (next lecture). This contains all the ready-to-run Ruby programs from each chapter.
This code archive contains all the programs from The Little Book Of Ruby.
First install a Ruby interpreter and a text editor or IDE. In this video I'll explain how to find and install the right interpreter for your operating system and I’ll show a couple of ways in which you can edit and run your Ruby programs.
If you are a Mac user, this video will guide you through the steps needed to write and run your first Ruby programs.
Here’s a quick tip that could save you a lot of time if you are running Ruby on a Mac. It explains how to use Finder to open a Terminal (for running Ruby programs) in any folder. Easy when you know how!
If you haven’t done much (or any) programming before or if you need a quick revision of the basics of programming, start with this video. This explains the fundamental features of computer programming – how to use variables, constants, methods, arguments and more.
Ruby can delimit strings with single quotes 'like this' or double quotes "like this". It turns out that double-quoted strings can do a special trick – they can evaluate embedded Ruby code. This lesson explains the fundamentals.
An introduction to objects and methods. How to use the standard methods of Ruby objects and how to create objects with methods of their own.
Hands-on sessions are where I encourage you to get at your keyboard and try out bits of Ruby. This hands-on session doesn't introduce new concepts but it does give you some guidance on how to experiment with Ruby as an aid to your study.
Now we’ll look at how multiple objects can be created from a class and we’ll see how to create and access ‘instance variables’ to store different data for each object.
How to initialize an object’s data at the time of creation using the initialize() method and how to look inside objects using the inspect() and p() methods.
Test your knowledge of the first two steps.
In this step you will learn how to create class hierarchies in Ruby so that descendent classes inherit the features of their ancestors.
This video summarizes the essentials of class inheritance in which different ‘branches’ of subclasses can descend from a common ancestor.
We look at simple ways of creating 'attributes' to access instance variables without having to write 'getter' and 'setter' methods.
What is the difference between an @instance_variable and a @@class_variable? This video explains...
An introduction to creating arrays in Ruby, including arrays of mixed types. How to index a single array item and how to append arrays.
How to index multiple sequential elements in an array, how to specify ranges of elements, and how to iterate over array items.
Time to get back to your keyboard and do some hands-on coding. In this video I suggest that you copy and paste code from the documentation of Ruby's class library. That's a great way to learn about the classes and methods available!
Hashes (or 'dictionaries') let you create lists of objects indexed using a key – for example, a string key such as "chocolate cake" may index a value such as the cake’s recipe. This step explains the fundamentals of hashes.
Ruby can return arrays of all the keys and values found in a hash. You can then use array methods to add, delete, reverse and append one array to another.
Test yourself on steps 5 and 6.
How to repeat actions and iterate over collections using for and while loops and some special Ruby methods.
Ruby uses Blocks to perform iterative actions. But there is more to Blocks than meets the eye. In a sense, a Ruby Block is like a method without a name. This video explains.
How to perform tests using 'if', 'elseif' and 'case' statements along with a number of operators to determine whether test conditions are true or false.
Ruby has quite a few Boolean operators to test true/false values. They may look simple enough at first sight but be careful. They may not always work quite as you expect!
Modules let you wrap up code for easy reuse – they also provide some of the features of multiple inheritance without the complexities.
What is the difference between a local and a global variable? And when is a constant not a constant?
Huw Collingbourne is the technology director at SapphireSteel Software, developers of the “Sapphire” Ruby IDE for Visual Studio and the “Amethyst” IDE for the Adobe Flash Platform. He is author of The Book Of Ruby from No Starch Press. He runs Bitwise Courses and teaches courses on a range of programming topics.
Huw has been a programmer for more than 30 years. He is a well-known technology writer in the UK. For over ten years he wrote the Delphi and Java programming column for PC Plus Magazine. He has also written numerous opinion and programming columns (including tutorials on C#, Smalltalk, ActionScript and Ruby) for a number of computer magazines, such as Computer Shopper, Flash & Flex Developer’s Magazine, PC Pro, and PC Plus. He is the author of the free ebook The Little Book of Ruby and is the editor of the online computing magazine Bitwise.
In the 1980s he was a pop music journalist and interviewed most of the New Romantic stars, such as Duran Duran, Spandau Ballet, Adam Ant, Boy George, and Depeche Mode. He is now writing a series of New Romantic murder mysteries.
At various times Huw has been a magazine publisher, editor, and TV broadcaster. He has an MA in English from the University of Cambridge and holds a 2nd dan black belt in aikido, a martial art which he teaches in North Devon, UK. The aikido comes in useful when trying (usually unsuccessfully) to keep his Pyrenean Mountain Dogs under some semblance of control.