Meaby it is good for you to know that also exist: attr_reader and
attr_writer. First one just create a "reader method" of the instance
variable passed as argument to attr_reader, second one just let you
change the instance variable passed as argument to attr_writer, not read
it.

 class Foo
   attr_reader :x
   attr_writer :y
   def initialize
      @x = rand
      @y = rand
   end
 end

 Same as...

 class Foo
   def initialize
     @x = rand
     @y = rand
   end
   def x
     @x
   end
   def y=(value)
     @y = value
   end
 end

-- 
Posted via http://www.ruby-forum.com/.