On Wed, 7 Feb 2001, Jim Freeze wrote:

> I have a question about some code in the pickaxe book on page 103:
> 
> module Notes
>   attr :concertA
..
> end
> 
> class Trumpet
>   include Notes
..
> end
> 
> 
> Trumpet.new(-5.3)
> 
> Returns:
> Instance method returns 434.7
> Instance variable is 434.7
> 
> I don't understand where the instance method 'concertA' is defined. I see
> that the instance variable '@concertA' is defined.
> 
> Can someone please explain this to me.

At module Notes we call method attr passing symbol :concertA as a
parameter. It builds up the method for you. You can also write it by
yourself, by saying

    def concertA
      @concertA
    end

instead of 'attr :concertA'. Please check attr_reader, attr_writer and
attr_accessor from the reference:

  http://www.rubycentral.com/ref/ref_c_module.html#attr_accessor

I welcome you to the fabulous world of class definition building.

    - Aleksi