background preloader

Ruby Basic Tutorial

Ruby Basic Tutorial
Troubleshooters.Com, Code Corner and Ruby Revival Present Ruby Basic Tutorial Copyright (C) 2005 by Steve Litt Note: All materials in Ruby Revival are provided AS IS. By reading the materials in Ruby Revival you are agreeing to assume all risks involved in the use of the materials, and you are agreeing to absolve the authors, owners, and anyone else involved with Python Patrol of any responsibility for the outcome of any use of these materials, even in the case of errors and/or omissions in the materials. If you do not agree to this, you must not read these materials. To the 99.9% of you honest readers who take responsibility for your own actions, I'm truly sorry it is necessary to subject all readers to the above disclaimer. CONTENTS This is a Ruby tutorial for one not knowing Ruby. Ruby can be used as a fully object oriented language, in which case you'd create classes and objects to accomplish everything. This is the simplest possible Ruby program, hello.rb. Let's count to 10... Retry

http://www.troubleshooters.com/codecorn/ruby/basictutorial.htm

Related:  Ruby Coding

Ruby Variables, Constants and Literals Variables are the memory locations which hold any data to be used by any program. There are five types of variables supported by Ruby. You already have gone through a small description of these variables in previous chapter as well. These five types of variables are explained in this chapter. Ruby Global Variables: Introduction to Ruby Programming - Online Course Learn how to create an interactive Web blog that allows visitors to register and post articles and comments. You'll see how to use the Ruby on Rails framework environment to create a full-featured Web blog using the Ruby programming language and the MySQL database server. We'll walk through the development of a complete Web blog application. During the course, you'll see step-by-step how to create all of the software and database objects used in the application. We'll begin by looking at exactly what the Ruby programming language is. Ruby has taken the Web world by storm, providing an object-oriented approach to Web programming.

Ruby Programming/Syntax/Method Calls A method in Ruby is a set of expressions that returns a value. With methods, one can organize their code into subroutines that can be easily invoked from other areas of their program. Other languages sometimes refer to this as a function. A method may be defined as a part of a class or separately. Method Calls[edit] Methods are called using the following syntax: Documentation Here you will find pointers to manuals, tutorials and references that will come in handy when you feel like coding in Ruby. Installing Ruby Unless you only want to try Ruby in the browser (see the links below) you need to have Ruby installed on your computer. You can check whether Ruby already is available by opening a terminal and typing This should output some information on the installed Ruby version.

AJAX on Rails 2.1 Tutorial Advertisements Ajax stands for Asynchronous JavaScript and XML. Ajax is not a single technology; it is a suite of several technologies. Ajax incorporates the following: Learn Ruby The Hard Way This exercise has no code. It is simply the exercise you complete to get your computer to run Ruby. You should follow these instructions as exactly as possible. For example, Mac OS X computers already have Ruby 2, so do not install Ruby 3 (or any Ruby). A major part of this book is learning to research programming topics online. I'll tell you to "search for this on the internet," and your job is to use a search engine to find the answer.

Ruby Programming Ruby is an interpreted, object-oriented programming language. Its creator, Yukihiro Matsumoto, a.k.a “Matz,” released it to the public in 1995. Its history is covered here. Its many features are listed here. 21 Ruby Tricks You Should Be Using In Your Own Code Writing for Ruby Inside, I get to see a lot of Ruby code. Most is good, but sometimes we forget some of Ruby's shortcuts and tricks and reinvent the wheel instead. In this post I present 21 different Ruby "tricks," from those that most experienced developers use every day to the more obscure. Whatever your level, a refresh may help you the next time you encounter certain coding scenarios. Note to beginners: If you're still learning Ruby, check out my Beginning Ruby book.

Learning Ruby methods and how you should use them What Are Methods and Why Do We Need Them? You'll often have a piece of code that needs to be executed many times in a program. Instead of writing that piece of code over and over, there's a feature in most programming languages called a procedure, which allows you to extract the common code to one place. In Ruby, we call it a method.

Ruby Programming/Ruby basics As with the rest of this tutorial, we assume some basic familiarity with programming language concepts (i.e. if statement, while loops) and also some basic understanding of object-oriented programming. We'll deal with variables in much more depth when we talk about classes and objects. For now, let's just say your basic local variable names should start with either a lower case letter or an underscore, and should contain upper or lower case letters, numbers, and underscore characters.

Ruby Regular Expressions A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings using a specialized syntax held in a pattern. A regular expression literal is a pattern between slashes or between arbitrary delimiters followed by %r as follows: Syntax:

Related: