Hi Vidhi,

You seem to have a lot of questions!  You would probably really benefit 
from buying the book "Programming Ruby" by Dave Thomas.  He answers a 
lot of the questions you're asking, and a lot more besides.

It takes you all the way from the very basic things, the ones you're 
having some troubles with, all the way to the really advanced stuff.

http://pragmaticprogrammer.com/titles/ruby/

You can buy a paper version, a PDF, or both!  I'd recommend both.  The 
paper copy is great for sitting and reading, but you can take the PDF 
with you, and can search through it easily.

Ben