The Twor-Bot

Ruby Class

| Comments

This blog post is for the software zairza ruby class.

Unfortunately the classes that I have taken were not effective due to technical issues and power cuts. So through this blog I will explain everything.It’s again raining.So let’s hack some codes now.

Installation Procedure:

For installation in windows go to Ruby Installer and download the 2.0.0 version. While installing allow the installer to set the path for you.In short tick the blank spaces while installing to set the path.

And after that open up your command line (cmd) by pressing the windows button and searching for cmd in the search bar.

And write

ruby -v

in the cmd and Enter.

If you find something like this

ruby 2.0.0p451 (2014-02-24 revision 45167)

Then it’s perfectly fine.

If you are getting some error message like

ruby: no internal or external command

Then reinstall it and tick all the path configuration stuffs while installing.

Or follow the instructions here. TutorialsPoint

For Debian based systems go to Ruby with rbenv and follow the instructions to install ruby with rbenv.

Text Editor:

For a good text editor go to sublimetext and download as per your OS and install it.

Then go to

Ruby Class

and click on download zip at the right hand bottom. It will download a zip file of my class codes and from the zip file extract all the files.

Make sure that you have the files like

1. add_and_power.rb
2. cars.rb
3. age.rb
4. blocks.rb
5. loop.rb
6. README.md

in a folder (ruby-class-master).

Save the folder in Desktop. (Do this for now. Save it in Desktop only)

Forget the README.md file for now.

People who have the folder already(from the class) also need to do this because I have modified the files a bit.

Then again hit your windows button and search for sublime editor (or any other code editor you have) and do the following from the left hand top.

file -> open file-> Then go to the folder ruby-class-master (where u saved after extracting) and open the addandpower.rb file.

You can do it to all other files and view the codes in the text editor. I have explained everything in the code files using comment lines (lines starting with a #).

And if I have mentioned to uncomment some lines just remove the # and it will be done. And if you are modifying anything, don’t forget to save the files.(ctrl + s)

Running the codes:

open up your cmd: you will get something like this

C:\Users\your_pc_name >

This is the current path where your cmd is. Then you need to go to the folder ruby-class-master so that you can access the files.For that you need to change the directory. I will teach those later in detail but for now save the folder ruby-class-master in Desktop.

Then run the command in cmd

cd Desktop/ruby-class-master

Then Enter and you can see the change like

C:\Users\your_pc_name\Desktop\ruby-class-master >

If this comes, you are now in the ruby-class-master folder and you can access all the ruby files from there. If you are getting some errors, let me know. :)

To run a file , for example addandpower.rb file, you just write

ruby add_and_power.rb

in the cmd and hit Enter and the code will be running and have fun. :)

You can do it to all other files.

Read all the comment lines in the codes. Those are pretty important and run the files to understand what is happening.

In the file blocks.rb I have mentioned nothing. This is a different concept called blocks and I want you guys to have a look at the code and run it. After running, gather the output. This is your task. In the next class, try to explain me why that output is there. Then I will introduce you to blocks, because it was difficult to write everything for blocks. If you are uncomfortable, then leave that blocks.rb file. We will discuss that in the next class.

Have fun guys and do let me know, if there is some trouble. I am always there. :)

Ask the doubts anywhere.

Mail Id is - tworitdash@gmail.com

Thanks !! :)

Comments