THE CODE WORD…..PHPXml ||a documentery by koyel banerjee

August 25, 2009

RUBY BIBLE

Filed under: Uncategorized — kopecks89 @ 5:07 pm
Tags: , , , , ,

Hello everyone,

long time since updated this coloum.Nevermind this time i have certain upates on the project “Deploying Gitorious in fedora” mentored by Mbuf
(Shakthi Kannan).Well this work is a Ruby on rails project so i put my hands together to learn somebit on the topic,precisely ruby.Mbuf had earlier recommended me to go through RUBY ON RAILS by TIMOTHY FISHER.In his language its the best for any newcomer and truely i find it no less.Precise,yet clear.the best thing about ruby is that it is a purely object oriented language where you do not need to define the types of data you are inputing.It follows dynamic interpretation which the program gets compiled!the main requirements to get your machine run ruby is as follows:
1.ruby installation
2.rails framework
3.any database(preferably mysql)

well unlike other scripting language like php ruby doesn’t require any other servers and complex server configuration process.it has got an inbulid server sytem called the QWebrick that works fine.The main use or advantage of ruby is better code readability.the following command sets must help installa successful working ruby system in your system.

yum install ruby —>this will load your system with ruby
yum install rubygems—->this will load the ruby gems including gems like rmagick
yum install rubygem-rails—–>this will install the rails framework in your system
yum install emacs—->this is a text editor which allows good code writing for ruby not that a text editor won’t work but this ones just better.if you want to go through its command set then you can have a peek in a cheat sheet which Mbuf created:
http://www.google.co.in/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fwww.shakthimaan.com%2Fdownloads%2Fglv%2Fhyd%2Femacs-a-day-keeps-the-vi-zing-away.txt&ei=UfaRSt1HhI2MB-G1nesN&usg=AFQjCNH-nm2mlM-pUQ8PXhOIHN_CnrcQ6A&sig2=NHmAiBdSTp_ymC

yum install mysql—>this installs the mysql database.as such the project doesn’t require much of it but gitorious officially uses mysql.

Once you wriet a code you need to store it within a directory and you will be able to directly work the file from the console using
ruby .rb

in my case i created a ruby code inside my /media/disk-2/electronics/ruby on rails
the file was named rub1.rb.the code of rub1.rb is as follows:

class SimpleMaths
def add_numbers(a,b)
puts “you are adding two numbers is ruby”
puts a+b
end
end
numb=SimpleMaths.new
numb.add_numbers(3,5)

the respective o/p as obtained from the terminal is as follows:

[koyel@localhost disk-2]$ cd /media/disk-1
[koyel@localhost disk-1]$ ls
avg
Basics_Principles_of_RS.pdf
bitdefender 2010
cycles
devraj
downloads
Electronic Arts
electronics
enlightenment of an ignorant.rtf
firefox-tabs.ogv
fort knox firewall manual.pdf
g data i security
gitorious.mht
horror
if ms is the fairy whos the wand its win7.wmv
if ms is the fairy whos the wand its win7.wmv.tar
Image_Enhancement_techniques.pdf
images
impl_doc_2009.pdf
KOYEL.pptx
linux_cat92-inst.pdf
muzdev
muzy
New Folder (2)
norton
pana antivirus for win7
PCIS
php
poite
PowerDVD Ultra[9.0.1531][h33t][Dave3737]
PRIYANKA (H)
$RECYCLE.BIN
RECYCLER
saves
SetupBtwDownloadSE.exe
System Volume Information
thewayuptoheaven.pdf
TT072 – Dealing With Odd Filenames.ogv
TT073 – Testing Your Mem With Memtest.ogv
TT074 – Be a Sudoer.ogv
TT075 – Webmin.ogv
TT076 – unix2dos.ogv
TT077 – whatis man.ogv
TT078 – What’s in a uname.ogv
TT079 – The Friendly Backslash.ogv
TT080 – pkill when killall isn’t enough.ogv
vista drivers
wamp
watermark.ogv
webroot
win 7 bluetooth
windows 7 ati driver.exe
Windows7UpgradeAdvisor.msi
xclipxsel.ogv
[koyel@localhost disk-1]$ cd electronics
[koyel@localhost electronics]$ ls
ruby on rails
[koyel@localhost electronics]$ cd ruby on rails
bash: cd: ruby: No such file or directory
[koyel@localhost electronics]$ cd ruby\ on\ rails/
[koyel@localhost ruby on rails]$ ruby rub1.rb
you are adding two numbers is ruby
8
[koyel@localhost ruby on rails]$

The ruby on rails uses class which contains attributes and methods.however one must create an instance of an object which contains the method defined within the class.

numb=SimpleMaths.new
numb.add_numbers(3,5)

like these two lines prefebrably numb = SimpleMaths.new creats the instance while in the next line we specify the name of the method to be used.

till this folks,more updates to come soon so keep glued.

regards,
koyel

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.