Hello, Im new to the forum and new to Ruby, but I have
programmed before.  Im reading through this tutorial as my first venture
into Ruby: http://www.math.umd.edu/~dcarrera/ruby/0.3/index.html

I apologize if this is the wrong forum or I break any forum rules in
this post, please let me know if I do!

I am using Eclipse + RDT (http://rubyeclipse.sourceforge.net/) for my
IDE.

I am currently on this page of the tutorial
(http://www.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes2.html) and I
am having a performing the exercise at the bottom of the page.

Here is the code I have so far:

========================================================================
class Address
    attr_accessor :street, :city, :state, :zip
    def initialize
        @street = @city = @state = @zip = ""
    end

    def to_s
        @street + "\n" + \
        @city   + "\n" + \
        @state  + ", " + @zip
    end
end

class Person
    attr_accessor :first_name, :email
    attr_accessor :last_name, :address
    def initialize
        @first_name = @last_name = @email = ""
        @address = Address.new
    end

    def full_name
        @first_name + " " + @last_name
    end

    def to_s
        @first_name + " " + @last_name + "\n" + \
        @email + "\n"
    end
end

sandy_addr = Address.new
sandy_addr.street = "324 Campus Dr."
sandy_addr.city   = "College Park"
sandy_addr.state = "CO"
sandy_addr.zip = "55555"

sandy = Person.new
sandy.first_name = "Sandy"
sandy.last_name  = "Kohh"
sandy.address = sandy_addr
========================================================================

If I then run: 'puts sandy.address' it correctly outputs the address.
This bit of code was given to me in the tutorial.  However if I type
'puts sandy.person' I get the following error message:
'test_temp1.rb:43: undefined method `person' for #<Person:0x2f2324c>
(NoMethodError)'

I am lost because the def to_s inside the Person class looks exactly
like the def to_s in the Address class.  What am I missing or doing
wrong?  Thanks in advance!

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