Author Topic: Getting Started with Ruby  (Read 4062 times)

0 Members and 1 Guest are viewing this topic.

Offline parad0x

  • VIP
  • Royal Highness
  • *
  • Posts: 638
  • Cookies: 118
    • View Profile
Getting Started with Ruby
« on: January 16, 2013, 04:07:16 am »
I read ande's tut on python and there I saw Dark Nebulae requesting for  a Ruby tut.I asked to myself,"If I know Ruby(not perfectly),why can't I write a tut on getting started with Ruby."I didn't posted it in tut thread because it is a scripting language tut and it should be in the Scripting Language thread.The style of writing this tut is similar to the one written by ande on python scripting.Thanks to ande without whom I would not have written this tut in a simple way.Thanks ande.

                     Starting Ruby Scripting
                                                                                          --- A tut written by Mr. Perfect

1.) About Ruby-- According to wikipedia:
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. It was also influenced by Eiffel and Lisp. Ruby was first designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.
Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management; it is therefore similar in varying respects to Smalltalk, Python, Perl, Lisp, Dylan, Pike, and CLU.
The standard 1.8.7 implementation is written in C, as a single-pass interpreted language. The language specifications for Ruby were developed by the Open Standards Promotion Center of the Information-Technology Promotion Agency (a Japanese government agency) for submission to the Japanese Industrial Standards Committee and then to the International Organization for Standardization. It was accepted as a Japanese Industrial Standard (JIS X 3017) in 2011[8] and an international standard (ISO/IEC 30170) in 2012.[9] As of 2010, there are a number of complete or upcoming alternative implementations of Ruby, including YARV, JRuby, Rubinius, IronRuby, MacRuby (and its iOS counterpart, RubyMotion), and HotRuby. Each takes a different approach, with IronRuby, JRuby, MacRuby and Rubinius providing just-in-time compilation and MacRuby also providing ahead-of-time compilation. The official 1.9 branch uses YARV, as will 2.0 (development), and will eventually supersede the slower Ruby MRI.
Even most of the meatsploit modules and exploits are written in ruby.

2.) Installing Ruby--[/b]

On windows,you can download the Ruby installer from http://www.softpedia.com/get/Programming/Coding-languages-Compilers/RubyInstaller.shtml
On deb linux,with APT installed,type sudo apt-get install ruby.

To check if Ruby is installed correctly or not(in windows) open cmd and execute irb.
If you see something like this
Quote
C:\windows\system32>irb
irb(main):001:0>
This means you have installed it correctly. :)

On linux,execute irb in the terminal.If you see something like this
Quote
root@bt:~# irb
irb(main):001:0>
You are going right way. ;)

Starting scripting--
Scripting in Ruby is somewhat like python.Create ruby files with .rb extension and to run the file navigate to that directory and type "ruby <filename>.rb".Lets start now

Hello world in Ruby:
Quote
print "Hello World!"

Printing variables:
Quote
var1 = "Hello world!"
print var1

Doing some maths:
Quote
num1 = 15
num2 = 20
num3 = 25
sum = num1 + num2 + num3
print sum
OUTPUT:
60
Some sites which teach Ruby in interactive way:
http://rubymonk.com
http://www.codecademy.com/tracks/ruby
http://tryruby.org
And an excellent source for those who want some more sites:
http://iwanttolearnruby.com/

Note for the beginners: I would suggest using irb first before you move on the files.Learn irb because it shows how ruby works.
« Last Edit: January 16, 2013, 02:19:04 pm by Mr. Perfect »

Offline cr0n0s

  • /dev/null
  • *
  • Posts: 18
  • Cookies: -1
    • View Profile
Re: Getting Started with Ruby
« Reply #1 on: February 22, 2013, 12:01:52 pm »
A very good Ruby tut. I think I should take Ruby as my first language.