This tutorial will cover the basics of Ruby so you can create simple Ruby programs and be prepared for Ruby on Rails. It assumes you are already familiar with basic programming concepts.
Never programmed before? You can start by programming visually before learning the syntax of a specific language. Google Blockly is a good visual programming language for beginners. Check out the Learneroo Blockly Tutorial to learn programming by solving games. If you want more guidance, see the Code.org Blockly Tutorial.
Here's a brief review of the elements of programming:
- All programs consist of instructions for a computer to follow. For example a program can tell the computer to display a message when a user clicks on a button.
- Algorithms - Sometimes we want the computer to find a solution to a problem, such as finding the sum of a list of numbers or the shortest route between two cities. Programmers write a set of instructions, known as an algorithm, for the computer to follow to solve such problems. See The Algorithm for more info.
- Control structures are used to control the flow of a program so it executes code according to certain conditions. For example, an if statement will execute code once if a condition is true (and otherwise skip it), and a loop will repeatedly execute code while a condition is true.
- Variables are used to store values in programming, such as 42 or "potato". See the Java tutorial for more info: Variables and Variables in Programming and Algebra.
- Methods are used for running the same instructions multiple times without rewriting the code in different places. Other code can just call (or "invoke") the method and the method's code will be executed. Parameters are variables that a method takes in to do something with.
- Objects and Classes - Objects in programming are modeled off objects in the real world. An Object contains both data (stored in variables) and methods for doing things. Classes are templates for creating objects. See Objects and Classes for more info.
- Inheritance lets classes of code share methods and variables with each other. See Inheritance for more info.