These courses teaches you the basics of Ruby on Rails, to get started smoothly. Ruby on Rails is a web framework based on the MVC design pattern and using the interpreted and object oriented Ruby programming language.
Ruby is a fully object-oriented, cross-platform interpreted language. In addition to being very intuitive, Ruby can be used as a scripting language in the same way as PERL or others, but its recent rise is mainly due to the appearance of Ruby on Rails, an extremely powerful web framework based on Ruby . These courses will teach you the basics of this language, its strengths, etc.
Installation and basic concepts
Let's see how to install Ruby on Windows.
Nothing too complicated, just go to Ruby's page, then click on "Downloads", and download the One-Click Installer for Windows. All you have to do is choose your installation directory and validate until the installation procedure is complete.
Ruby comes with two editors by default: SciTe and FreeRIDE.
To launch FreeRIDE (written entirely in Ruby), go to the Ruby installation directory, then to the "freeride" directory, and run "run.bat".
I prefer SciTe, but that only depends on personal considerations. To launch it, go to the Ruby installation directory, then to the "scite" directory, and run "SciTE.exe".
In Ruby, everything is object. Absolutely everything. An integer, a string, and even classes, as surprising as it may seem.
First steps
We will learn by experience. For that, we will use irb (Interactive Ruby).
Using irb, we will be able to test Ruby's basic syntax and directly view the result, without having to create a file containing our code (a .rb) and modify it each time. You just have to launch a DOS window (start -> run -> cmd), then type "irb" in the command prompt, and validate.
Manipulation of simple variables
The command prompt has changed. You can now directly type your orders. Try typing the following lines:
- a = 2
- b = 3
- puts "a + b is worth" + (a + b) .to_s
Here's what you should get on the screen:
irb (main): 001: 0> a = 2
=> 2
irb (main): 002: 0> b = 3
=> 3
irb (main): 003: 0> puts "a + b is worth" + (a + b) .to_s
a + b is 5
=> nil
Many things in this simple example. We have just created two variables, a and b, and assigned them values. Then we decided to display their sum using the puts method. So we display a string (the part in quotation marks), which we concatenate to another string using the + operator.
This second string is actually the result of the sum of our two variables (again this time using the + operator, which does not have the same function depending on the type with which it is used), which we let's convert to a string using the to_s method (to make concatenation possible, we need two identical types).
You will notice that nowhere have we defined the type of a or b. Ruby manages like a big one: it's the duck typing (it looks like a duck, it behaves like a duck, so it's a duck).
Submitted On : 2017-06-17
Taille : 1,728.43 Kb
Downloads : 1522
Submitted On : 2017-06-17
Taille : 1,125.03 Kb
Downloads : 624
Submitted On : 2017-04-01
Taille : 4,213.89 Kb
Downloads : 1361
Submitted On : 2019-04-22
Taille : 2466.032 Kb
Downloads : 251
Submitted On : 2019-04-30
Taille : 1.87 MB
Downloads : 823
Submitted On : 2019-04-30
Taille : 2.06 MB
Downloads : 611
Submitted On : 2020-08-29
Taille :
Downloads : 62
Submitted On : 2020-08-29
Taille :
Downloads : 68
Submitted On : 2020-08-30
Taille :
Downloads : 698
Submitted On : 2021-05-15
Taille :
Downloads : 250
Submitted On : 2021-05-15
Taille :
Downloads : 242
Submitted On : 2021-05-15
Taille :
Downloads : 219
Submitted On : 2022-02-02
Taille : 6.4 MB
Downloads : 98
Submitted On : 2022-02-03
Taille : 2.6 MB
Downloads : 139
Submitted On : 2022-02-03
Taille : 4.0 MB
Downloads : 128
Submitted On : 2022-02-03
Taille : 3.5 MB
Downloads : 122
Submitted On : 2022-02-03
Taille : 1.9 MB
Downloads : 187
Submitted On : 2022-02-03
Taille : 2.1 MB
Downloads : 114
Submitted On : 2022-02-03
Taille : 0.5 MB
Downloads : 120
Submitted On : 2022-02-03
Taille : 2.0 MB
Downloads : 76